Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

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
");
	
  	if (strcmp(str1, str3) != 0)
        printf("str1 != str2
");
  
	return 0;
}
 
PREVIOUS NEXT
Tagged: #equal #string
ADD COMMENT
Topic
Name
9+7 =