0

So I am getting 2 strings from files I open and read. They are exactly the same but it doesnt seem to work this way. How would i make it work/do it differently?

This is the code:

FILE *file;
FILE *file2;
file = fopen("hey1.txt", "r");
file2 = fopen("hey2.txt", "r");

char line[32];
char line2[32];

while (fgets(line, 32, file) != NULL) {
    printf("%s\n", line);
}

while (fgets(line2, 34, file2) != NULL) {
    printf("%s\n", line2);
}

if (line==line2) {
    printf("The same\n");
}
else {
    printf("Not the same\n");
}
Martacus
  • 723
  • 6
  • 23

1 Answers1

1

You can't use == to compare strings.

Use

strcmp()
Gopi
  • 19,784
  • 4
  • 24
  • 36