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
Translate the following formula into a prefix form expression in Scheme: Question 2 Define a procedure that takes three numbers as arguments and returns the sum of the squ

COS-101: INTRODUCTION TO COMPUTERS PROJECT DESCRIPTION The Computer Fundamentals Project provides you with a chance to apply what you have learned about computer fundamentals to

Design an object definition named Pet, which should have the following fields: name: The name field holds the name of a Pet type: The type field holds the type of anima

The assignment has two parts: first you generate a simple application for a MID that operates independently of other MIDs. As a second part, the application is extended to keep so

Object-oriented programming paradigm Object  Oriented  Programming  is  an  aproach  in  which  a  program  is  viewed  as  a  dynamic  network  of collaborating objects, where

Question: (a) How do you implement the following in ASP.NET: (i) Server-side Comments (ii) Server-side Include Directives. (b) What is the purpose of a HashTable? (

Windows XP using C# load a binary file and send it thru a USB port to the USB port of STM32. STM32 received the file and then write it into an I2C EEPROM.

I''m doing a project for class in college and im supposed to use today''s date and figure out how old i am in months, days, minutes, and seconds. My question is what is the beset

Provide Example of Function? An illustration of a function definition main() { message(); } /* header */ message() { /*bodystarts here*/ printf ("Example for function

1.   You have been asked to write a computer program that will figure out the total of an order when given the amount of the order ($200) and a sales tax rate of five percent.  I w