plz answer.. a program that takes a string e.g. "345" and
returns integer 345

Answer Posted / ramu

int f(char s[])
{
int num=0,i;
for(int i=0;s[i]>='0' && s[i]<='9';i++)
n=10*n+(s[i]-'0');
if(i<sizeof(s))
{
printf("Error String");
return 0;
}
return n;
{

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you search data in a data file using random access method?

840


What's the difference between constant char *p and char * constant p?

660


Is null always defined as 0(zero)?

619


What is the meaning of 2d in c?

617


I have seen function declarations that look like this

606






Why c is known as a mother language?

650


What are the main characteristics of c language describe the structure of ac program?

616


What is a scope resolution operator in c?

756


How do you define a string?

660


What is the condition that is applied with ?: Operator?

667


How does #define work?

654


What does stand for?

602


What is f'n in math?

623


What are the application of c?

652


Can we add pointers together?

622