0

So ive ask a question early , heres the link : What is the value between a part of txt and another part of txt?

So to find out what character or value it is , i wrote a code that will printf "used" if it gets the value, heres the code :

char buffer[50];
    FILE *fr = fopen("data.txt", "r");
    fgets(buffer, 49, fr);
    printf("test%stest", buffer);
    if(buffer == '\0'){
        fclose(fr);
        fr = fopen("data.txt", "r");
        printf("\nUsed\n");
    }

'\0' is just an example, i tried to use all "control character" from here : Rules for C++ string literals escape character and the program still didnt print out "used", so im sooooo curious that what value is in the lines just like the question i asked earlier, or maybe i code the program that wrong.

L.Rat
  • 39
  • 6
  • 2
    Did you mean `if(buffer[0] == '\0')`? The variable `buffer` cannot be `'\0'` but one of its elements can. However it is more usual to check the return value from `fgets`. – Weather Vane Dec 01 '18 at 08:48
  • @Weather Vane Thx!! You need to use buffer[0] to check the value, after i change to it, it works !! thx alot! – L.Rat Dec 01 '18 at 08:51

0 Answers0