fwrite (junk characters)
807578Feb 13 2010 — edited Feb 14 2010Hi,
I have problem with this code it put the junk data in output file :
#include <stdio.h>
#include <string.h>
int main (int argc, char *arg[])
{
char data[6];
char fil_date[20];
memset ( data,"ALTA",5);
fp = fopen("abc.txt","w+");
sprintf(fil_data,"%5s-----hello",data);
fwrite(&fil_data,sizeof(fil_data),fp);
//fprintf(fp,"%5s---hello",data);
}
output file(abc.txt has data lik ):
ALTA^@^@^@
---- And if i remove the comment before fprintf() and comment the fwrite()
---- then the program is creating output file without junk characters.
why is this fwrite() adding junk in output file..