B
Bill Cunningham
I have been away from C for awhile and need a refresher. fgets 2nd
parameter takes an int but the 1st takes a string. When I compile what I
write everything works fine but this is what I type-
#include <stdio.h>
int main()
{
char p[5];
printf("enter code-> ");
fflush(stdout);
fgets (p,sizeof(int),stdin);
printf("%s\n",p);
return 0;
}
Everything's cool and works the way I want. But is there a similarity
with the 5 chars and the ints in fgets 2nd parameter? I shouldn've used 5
for int should I have?
Bill
parameter takes an int but the 1st takes a string. When I compile what I
write everything works fine but this is what I type-
#include <stdio.h>
int main()
{
char p[5];
printf("enter code-> ");
fflush(stdout);
fgets (p,sizeof(int),stdin);
printf("%s\n",p);
return 0;
}
Everything's cool and works the way I want. But is there a similarity
with the 5 chars and the ints in fgets 2nd parameter? I shouldn've used 5
for int should I have?
Bill