1.i am just trying to insert a "structure record" into a file using fwrite() function by the following code
2.
#include<stdio.h>
#include<conio.h>
struct student
{
char name[20];
int rollno;
};
void main()
{
FILE *fp1;
struct student s1={"",0};
clrscr();
printf("enter the details\n");
scanf("%s %d",s1.name,&s1.rollno);
printf("%d\n",s1.rollno);
fp1=fopen("empdet.txt","w");
fwrite( &s1,sizeof( struct student ),1,fp1 );
printf("the record is entered");
fclose(fp1);
getch();
}
3.when i executed the above program,it just inserting only the "name" field and
the "rollno" field with some garbage
4.please,someone help me....