strcspn c code example
Example 1: strcasecmp c
Upon completion, strcasecmp() shall return an integer greater than, equal to, or less than 0, if the string pointed to by s1 is, ignoring case, greater than, equal to, or less than the string pointed to by s2, respectively.
Example 2: strcmp c
string a = "words";
string b = "words";
if (strcmp(a, b) == 0)
{
printf("a and b match");
}
else
{
printf("a and b don't match");
}
Example 3: strcpy en c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char Temp[255];
strcpy(&Temp,"Gladir");
strcpy(&Temp,"ABC");
strcpy(&Temp,"Gladir.com");
puts(&Temp);
return 0;
}
Example 4: strncpy c
char *strncpy(char *dest, const char *src, size_t n)
Example 5: c strcmp
int strCmp(const char* s1, const char* s2) {
while(*s1 && (*s1 == *s2)) {
s1++;
s2++;
}
return *s1 - *s2;
}