When I used fputs()
to directly store a character array in a file, it stored this in the file:
ÈLwìþ(
Why was that?
#include <stdio.h>
int main()
{
FILE *p;
p=fopen("pa.txt","w+");
char name[100];
printf("Enter a string :");
fputs(name,p);
fclose(p);
getchar();
return 0;
}
When I take input in name using scanf()
or gets()
, the correct text is stored but when directly use fputs()
is used it stored in an unusual format.
Why does this happen?