Answers for "equal string c"

C
0

equal string c

#include <string.h>
// strcmp is a function from the stadard string library that returns 0 of both strings are equals

int main () {

	// for exemple
	char[] str1 = "Hey!";
  	char[] str2 = "Hey!";
  	char[] str3 = "Hola";
  
  	// instead of "if (str1 == srt2)" you'll need to use
  	if (strcmp(str1, str2) == 0)
        printf("str1 = str2\n");
	
  	if (strcmp(str1, str3) != 0)
        printf("str1 != str2\n");
  
	return 0;
}
Posted by: Guest on April-26-2022

Code answers related to "C"

Browse Popular Code Answers by Language