Syntax question

D

deppy_3

I have a problem in something mabye silly, but i have my mind stuck.

This a part of a code
------------------------------------------
main()
{
char age[10];
int k;

printf("Age :");
scanf("%s",age);
k=atoi(age);
if(k<1||k>100)
{
printf("Age :");
scanf("%d",&k);
}
 
R

Richard Heathfield

(e-mail address removed) said:
I have a problem in something mabye silly, but i have my mind stuck.

This a part of a code
------------------------------------------
main()
{
char age[10];
int k;

printf("Age :");
scanf("%s",age);

100000000000000000000000000000000000000000000000000000000000000000000000

How will your program handle that input?
k=atoi(age);

FORTYTWO

How will your program handle that input?
How can i convert the 'k' again so as to be string;

You can use sprintf to convert an int value to a string representation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,798
Messages
2,569,649
Members
45,382
Latest member
tallzebra

Latest Threads

Top