# include "stdio.h"
# include "string.h"
# define MAX 10
int main()
{
int fnStringtoInt(char*);
char cString[MAX];
printf("Enter the integer value to String variable\n");
gets(cString);
printf("The integer value is :%d\n",fnStringtoInt(cString));
return 0;
}
int fnStringtoInt(char *cString)
{
int nValue=0;
while(*cString != NULL)
{
nValue = (nValue*10)+(*cString-'0');
cString++;
}
return nValue;
}
OUTPUT:
Enter the integer value to String variable
1234456
The integer value is :1234456
Press any key to continue . . .
No comments:
Post a Comment