#include<stdio.h>
// use line f = fopen ("test.txt", "wb"); and open the file
// in notepad: no new lines! But if you open it in visual C's editor, you see
// new lines. (\n is really two characters: one goes to the next line but
// at the same location as the line above it, and another one goes to the
// beginning of the new line).
// Now change "wb" to "w" to write in ASCII instead of binary
struct Daneshjoo {
int shomareD;
char esm[80];
double nomre[20];
};
void main ()
{
char matn[1024];
char str[80];
int i=23456;
double A[200];
FILE *f;
struct Daneshjoo daneshjoohaa[100];
f = fopen ("test.txt", "wb");
if (!f) { // f==NULL
printf("Cannot open test.txt for writing.\n");
return;
}
fprintf(f, "Salam sosis!");
fwrite(A, sizeof(A[0]), 200, f);
fwrite(&daneshjoohaa[4], sizeof(struct Daneshjoo), 1, f);
fwrite(&daneshjoohaa[0], sizeof(struct Daneshjoo), 100, f);
fprintf(f, "Salam kalbas!");
//while (!feof(f)) {
// fscanf(f, "%d", &i);
// printf("%d\n", i);
//}
fclose(f);
}