How do I change the contents of the file to *
I need to change the contents of this file to *
For each letter in the file I need a *
It's a programme to play hangman so I need the stars to 'cover' the letters that the user will have to guess. I just don't know how to print the contents of the file using stars instead. I don't want to put stars in the file instead of the letters because the user will have to guess them later. this is what I have written so far:
Code:
char filename[FILENAME_MAX + 1];
FILE *fpin, *fstar;
char temp, x, i;
char readfile[SIZE];
char *read;
printf("\nGet the filename with the unknown word: ");
scanf("%s", filename);
fpin=&filename[FILENAME_MAX +1];
if((fpin = fopen(filename, READONLY)) == NULL){
printf("Cannot open file\n");
exit(EXIT_FAILURE);
}
printf("\nReady to start");
if(fputc(x, fpin) == EOF){
if(!feof(fpin)){
printf("\nError reading from input file");
}
else if{
printf("\nEnd Of File");
}
else{
printf("\nmain: error writing to output file");
break;
}
}
i=fputc(x, fpin);
printf("\n%c", i);