scanf() vs gets()
From: Teh Charleh (onegaitanteidan_at_aol.comnojunk)
Date: 11/30/03
- Next message: Ben Pfaff: "Re: scanf() vs gets()"
- Previous message: Jack Klein: "Re: Calling C functions from Tk script."
- Next in thread: Ben Pfaff: "Re: scanf() vs gets()"
- Reply: Ben Pfaff: "Re: scanf() vs gets()"
- Reply: Mike Wahler: "Re: [FAQs] scanf() vs gets()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Nov 2003 20:08:33 GMT
OK I have 2 similar programmes, why does the first one work and the second does
not? Basically the problem is that the program seems to ignore the gets call if
it comes after a scanf call. Please anything even a hint would be really
helpful, I cant for the life of me see why the 2nd prog wont work...
gets before scanf
code:---------------------------------------------------------------------
-----------
#include <stdio.h>
int a;
char aaa[50];
main()
{
printf("Enter a string\n");
gets(aaa);
printf("%s\n",aaa);
printf("Enter a number\n");
scanf("%d",&a);
printf("%d",a);
}
--------------------------------------------------------------------------
------
scanf before gets
code:---------------------------------------------------------------------
-----------
#include <stdio.h>
int a;
char aaa[50];
main()
{
printf("Enter a number\n");
scanf("%d",&a);
printf("%d",a);
printf("Enter a string\n");
gets(aaa);
printf("%s\n",aaa);
}
- Next message: Ben Pfaff: "Re: scanf() vs gets()"
- Previous message: Jack Klein: "Re: Calling C functions from Tk script."
- Next in thread: Ben Pfaff: "Re: scanf() vs gets()"
- Reply: Ben Pfaff: "Re: scanf() vs gets()"
- Reply: Mike Wahler: "Re: [FAQs] scanf() vs gets()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|