In C, you need to use a function that compares strings for you. By doing this, you simply say if there are two lines in one place in memory. So
char a[] = "hello world"; char b[] = a;
creature
a == b;
will give you a true value, since both a and b point to the same place or line in memory.
If you want to compare two strings, you will need to use strcmp()
, which returns 0 if the strings are equal.
if( strcmp(a, b) == 0 ) printf("True\n"); else printf("False\n");
To use it, you need to enable the string.h library.
#include <string.h>
source share