1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
int main() {
FILE *myfile = fopen("file.txt", "w+");
int arr1[] = {4, 5, 6, 7, 2, 3};
int arr2[] = {1, 8, 9, 10, 11};
int t;
if (NULL != myfile) {
for (t = 0; t < sizeof arr1 / sizeof arr1[0]; ++t)
fprintf(myfile, "%d ", arr1[t]);
fputc('\n', myfile);
for (t = 0; t < sizeof arr2 / sizeof arr2[0]; ++t)
fprintf(myfile, "%d ", arr2[t]);
}
else {
ferror("Can't create or open the file!");
return 1;
}
return 0;
}
|