(Choose 1 answer)
FILE *fp = NULL;
fp = fopen("alpha.txt","w");
if (fp != NULL) {
fprintf(fp, "%s", "We are the world!");
fclose(fp);
} else printf("Failed to open file");
The above code is the correct structure to:
A. (1) connect to file, (2) open the file to write data, (3) write data to file, and (4) close the file.
B. (1) connect to file, (2) open the file to read data, (3) read from file, and (4) close the file.
C. (1) connect to file, (2) open the file to read and write data, (3) write data to file, and (4) close the file.
D. (1) connect to file, (2) write data to file, (3)open the file to write data, and (4) close the file.