I have this small code that is only inverting the text in a file character by character and its working perfectly fine, the problem is that it always adds a '%' at the end.
FILE *fd;
int main (int argc, char *argv[]) {
if ((fd = fopen(argv[1], "r")) != NULL){
int ft = 0;
int i = 0;
fseek(fd, 0, SEEK_END);
ft = ftell(fd);
while(i < ft)
{
i++;
fseek(fd, -i, SEEK_END);
printf("%c", fgetc(fd));
}
printf(" ");
fseek(fd, 0, SEEK_END);
fclose(fd);
}
else {
perror ("File does not exist !!!\n\a");
}
return 0;
}
The input text is : Taco cat
And the output is : tac ocaT %
So i can't find a way to get rid of this pesky % sign. Im in linuxmint.