Hello, I'm new with C and I've almost finished this little program but something is wrong.
The program reads in a list of names from the file names.txt that I put right in C:, and prints the list to an out file called trans.txt (which it creates on its own) and prints the list to the screen. It executes but only prints the user instructions, and not the names.
I even searched all of C: for trans.txt and there is no sign of it, even though I told the program to create it directly in C:. I am not sure what to do or what is happening, any help would be appreciated.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char names[20][60];
int i, j;
char name;
void main(void)
{
FILE *in, *out; /* access to in.txt files */
printf("This program will read in names from the \nfile names.txt and print out to trans.txt.\n");
in = fopen("c:\\names.txt", "r");
out = fopen("c:\\trans.txt", "w");
for (i=0; i<20; i++)
for(i=0;i<60;i++)
names[i][j]=' ';
for (i=0;i<20; i++)
{
fgets(&names[i][j], sizeof names[i][j], in);
if (names[i][j]=='\0' || names[i][j]=='\n')
printf (" ");
else
{
names[i][j]=names[j][i];
printf("%c", names);
}
}
}