Stick with what you are using now. Don't get caught doing a good program, and then having it marked down because you used a different compiler than the one the professor is using.
Give this a look over with your compiler, and see how it does:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char words[][2][40]= {
{"adorer","adore"},
{"gras","greasy"},
{"outil","tool"},
{"radis","radish"},
{"tracer","trace"},
{"",""}
};
int main(void)
{
FILE *fp;
int i;
if(( fp=fopen( "myfile", "w" )) == NULL) {
printf("Cannot open file.\n");
exit(1);
}
//print out the original string array to the file
for(i=0;i<6;i++) {
fprintf( fp, "%s %s ", words[i][0], words[i][1]);
}
fclose(fp);
//show the original string array
for(i=0;i<6;i++) {
printf( "%s, %s, ", words[i][0], words[i][1]);
}
if(( fp=fopen( "myfile", "r" )) == NULL) {
printf("Cannot open file.\n");
exit(1);
}
//reread the file strings
for(i=0;i<6;i++) {
fscanf( fp, "%s %s ", words[i][0], words[i][1]);
}
fclose(fp);
printf("\n\n Reloaded values from the file are:\n");
for(i=0;i<6;i++) {
printf( "%d: %s, %s, \n", i,words[i][0], words[i][1]);
}
printf("\n");
return 0;
}