Program converts character array to signed decimal integer, Programming Languages

1. Write a function that converts a character array to a signed decimal integer. Function prototype must be as follows: int asciiToInt( char *str, unsigned char* eflag)

YOU MAY NOT USE THE LIBRARY ATOI AND ATOF FUNCTIONS, but you may use any string library function.

The function must only have two parameters. str is the character string to be converted.

a) If the string has any leading non-numeric characters other than + or -, your function should print an error message, set eflag to 1, and return 0.

b) Any non-digit characters other than 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 should also result in an appropriate error message, setting the eflag to 1 and returning 0.

c) Otherwise, your function should convert numeric ascii character string to the appropriate signed integer value. The eflag should be zero for a successful conversion. Return the signed integer value.

d) Examples of invalid strings:

A10

1239z45

e) Examples of valid strings:

+123

-99

12

0

For an entry such as -0, return 0.

f) Include comments in the form:

/** Function name:

*

* Desription:

* Input:

* Output:

*/

Posted Date: 3/7/2013 12:34:43 AM | Location : United States







Related Discussions:- Program converts character array to signed decimal integer, Assignment Help, Ask Question on Program converts character array to signed decimal integer, Get Answer, Expert's Help, Program converts character array to signed decimal integer Discussions

Write discussion on Program converts character array to signed decimal integer
Your posts are moderated
Related Questions
How do you print triangles using for loops and if statements

Question 1: a) Assume that B is an array of 50 words; write a code which will place the smallest integer of array B in register AX. b) Write a small code (only three instr

Flatten the tree Consider the following XML input, which groups people into two categories-salaried and hourly: Warren Rosenbaum 37 5.75

Term project (you should code a function), demonstrate it to the class and a very breief report (one or two pages) describing what you did. You determine your project (could be imp

* Comments in your code are required * Main Program Operation:  # Your program should first prompt the user for an integer to seed the random number Generator. "Enter an seed

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

The standard way for debuggers to plant interactive breakpoints in a program in RAM (whatever the processor instruction set) is to save the break pointed instruction and replace it

about how to create the program in c

ASP.NET and ASP.NET AJAX ASP.NET AJAX, formerly known as "Atlas", is an Enthusiasm rendering of an AJAX centered structure, designed for ASP.NET (although it can be used on other s

1.  Develop HTML code to create a Web page with the red background and title "My First Page" in any other color. 2.  Develop an HTML document with details of your name, telephon