#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv){
FILE *fp;
if((fp=fopen("Example.txt", "r"))== NULL){
printf("Errore apertura file");
exit(0);
}
char s[50];
int i=0;
while(!feof(fp)){
if(!feof(fp)){
s[i++]=fgetc(fp);
}
}
s[i]='\0';
fclose(fp);
char nome[20];
printf("Inserisci il nome che vuoi dare al file di uscita\n");
//fgets(nome,20,stdin);
scanf("%s",& nome);
char tipo[5]=".txt";
strcat(nome,tipo);
if((fp=fopen(nome,"w"))== NULL){
printf("Errore apertura file");
exit(0);
}
fputs(s, fp);
fclose(fp);
return 0;
}
The output file over the string is even printed an abnormal character, how can I not see it? The output is "string"+'ÿ'` The problem is only in the output file and not in the capture.