Last active
July 16, 2017 05:50
-
-
Save DeclanHoare/218262fb9c6f17f28ef761515e65fd6d to your computer and use it in GitHub Desktop.
why does it use conio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Chapter 8 Example 8.8 */ | |
/* ////////////////////////////////////////// | |
program: EXAM_8_8.C | |
This program reads strings from a 2-d array | |
and stores them in a data file | |
///////////////////////////////////////// */ | |
#include <stdio.h> | |
#include <conio.h> | |
#define ROWS 10 | |
#define CHARS 20 | |
FILE *fp1; | |
int main(void) | |
{ | |
char names[ROWS][CHARS] = { | |
"Antonius", "Barnabas", | |
"Caesar", "Dorian", | |
"Ethelbreda", "Frankenstein", | |
"Goliath", "Henrietta", | |
"Indiana", "Juno" | |
}; | |
int thisrow; | |
clrscr(); | |
fp1 = fopen("newnames.dat", "w"); | |
if (fp1 == NULL) | |
{ | |
printf("Unable to open file.\n"); | |
return (1); /* unsuccessful so quit program */ | |
} | |
for(thisrow = 0; thisrow < ROWS; thisrow++) | |
fprintf(fp1, "%s\n", names[thisrow]); | |
fclose(fp1); | |
return(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment