strcpy library c++ code example
Example 1: strcpy
/* strcpy example */
#include <stdio.h>
#include <string.h>
int main ()
{
char str1[]="Sample string";
char str2[40];
char str3[40];
strcpy (str2,str1);//str1 copies to str2
strcpy (str3,"copy successful");
printf ("str1: %s\nstr2: %s\nstr3: %s\n",str1,str2,str3);
return 0;
}
Example 2: strcmp c++
int strcmp ( const char * str1, const char * str2 );
// returning value | indicates
// <0 the first character that does not match has a lower value in ptr1 than in ptr2
// 0 the contents of both strings are equal
// >0 the first character that does not match has a greater value in ptr1 than in ptr2