Hey guys, I'm getting a segmentation fault and I'm trying to sort it out but I have no idea why I'm getting it.
Code:
char input[20];
printf("Qual o .txt que deseja abrir ?\n");
fgets(input,20,stdin);
FILE *fp;
input[strlen(input)-1] = '\0';
fp = fopen(input,"r");
if (fp==NULL)
{printf("Nao foi possivel abrir o seu ficheiro\n");}
else leadj(fp,18);
In case I input a .txt that doesn't exist the printf works fine but when I do input a .txt that does exist the leadj(fp,18) is getting me a segmentation fault and I have no clue why taking in fact that if I do it on main it works
Any ideas ?