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
Let S =  {s 1 , s 2 , .... , s k } denote a set of k genomes. The problem of fingerprinting is the task of identifying a shortest possible substring α i from each string si such t

Vacation Envy - Travel and Photo Sharing Website Site Overview- Vacation Envy is a travel as well as photo-sharing site. Make your travel map, share photos and show off al

Implement a two-dimensional table in Prolog. Your program will contain: 1.  An insert_entry predicate that takes a table, row, column and an entry and inserts the entry at the g

Let us say we have a list of 10 animal objects called "animals" in Alice. Write the code to move them forward synchronously by 1 meter.

We want a program that will allow us to print a "grade list" of the students in a class. The program should loop, asking for a name, midterm score, and final score. It should th

Question 1 Discuss on Inheritance Question 2 What are the four phases of the object modeling technique that can be repetitively executed? Question 3 Explain the di

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

NOTE: You will only submit the University.java and EmptyFileException.java files (inside P3.zip/tar) NOTE on null objects:. From Project 1: Since the array of students in the Cou

How do you get the complexity of an algorithm? What is the relation b/w the time & space complexities of an algorithm? Justify your answer with an example.

Create the class Robot described in the Karel++ book. Description: The Robot class described in the Karel++ text is a derived class of ur_Robot. Create class Robot as a d