T
Teh Charleh
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);
}
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);
}