compare 2 char * in c++ code example
Example 1: how to compare two char* in c++
#include <string.h>
...
if (strcmp(firstSTR, secondSTR) == 0) {
// strings are equal
...
} else {
// strings are NOT equal
}
Example 2: strcmp c++
#include<stdio.h>
#include<string.h>
int main()
{
char char1[] = "coucou";
char char2[] = "coucou";
if( strcmp(char1, char2) == 0 )
printf("Strings are the same");
else
prinf("Strings are differentes");
return 0;
}