1

I have a binary file called signatures, and I tried to open it in my program, based on user-input. I realized it doesn't actually open when I input the exact file name and I can't figure out why.

Here is the code I wrote to test the matter:

char buffer[1024];

fgets(buffer, 1024, stdin);

FILE* file = fopen(buffer, "rb");
if(file){
    printf("worked");
    fclose(file);
}

when I type in "signatures" the file still doesn't open. However, if I do the following:

FILE* file = fopen("signatures","rb"); 

it actually does open. What could be the problem?

I'm running this on ubuntu 18.04 on a virtualbox virtual machine with windows 10 as host.

giorgioh
  • 377
  • 1
  • 13

0 Answers0