Skip to content

Instantly share code, notes, and snippets.

@DeclanHoare
Last active July 16, 2017 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeclanHoare/218262fb9c6f17f28ef761515e65fd6d to your computer and use it in GitHub Desktop.
Save DeclanHoare/218262fb9c6f17f28ef761515e65fd6d to your computer and use it in GitHub Desktop.
why does it use conio
/* 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