io - How to write an array to file in C -
i have 2 dimensional matrix:
char clientdata[12][128];
what best way write contents file? need update text file on every write previous data in file cleared.
since size of data fixed, 1 simple way of writing entire array file using binary writing mode:
file *f = fopen("client.data", "wb"); fwrite(clientdata, sizeof(char), sizeof(clientdata), f); fclose(f);
this writes out whole 2d array @ once, writing on content of file has been there previously.
Comments
Post a Comment