c - Writing in to dat file clearing old data -


i trying write student.dat file.my problem when writing second time first data clearing out.please me

student st;  file* fp = fopen("d:\\student.dat", "w"); //fseek(fp,0,seek_set);    st.getdata();       fwrite((char *) &st,sizeof(student),1,fp); fclose(fp); printf("\n\nstudent record has been created "); fflush(stdin);    getch(); 

try append mode:

file* fp = fopen("d:\\student.dat", "a"); 

w mode overwrites file: "create empty file output operations. if file same name exists, contents discarded , file treated new empty file."


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -