I'm trying to print out a 16 by 17 character array that I've included from a text file. I am able to open the file okay. However, instead of printing the character array, the program prints a series of smiley faces. Do you know how I can get my string to print? I appreciate any input. Thanks, Cynthia
Code:
char hor_wordsearch[17][17];
char ver_wordsearch[16][17];
int i=0,j=0;
FILE *myFile;
myFile = fopen("hor_wordsearch.txt", "r+");
if (myFile == NULL)
{
printf("Unable to open hor_wordsearch.txt.\n");
return(-1);
}
printf("Opened hor_wordsearch.txt for reading.\n");
//I am able to open the text file without difficulty, but I'm having trouble initializing and printing my arrays
for (i=0; i<16; ++i)
{
hor_wordsearch[i][16]= '\0';
ver_wordsearch[i][16]= '\0';
}
while (!feof(myFile))
{
fgets(hor_wordsearch[i], 17, myFile);
printf("%s", hor_wordsearch);
}
fclose(myFile);