fprintf(file, "%d %d %d", array[0], array[1], array[2]);
for this statement to work i have to open the file in ‘wb’ mode rather than ‘w’ mode . How does a binary mode make the syntax work?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First get a file pointer using fopen
FILE *fp = fopen(“file.bin”, “r+”);
Then use fread to read and fwrite to .. write. See this
Also please do read the manual carefully and note fread and fwrite return an integer which should be checked to see exactly how much has been read/written.