Built-in Functions for NTCAs
strlen char array[10] = “Hello”; int length = strlen(array); cout << length;
strlen char array[10] = “Hello”; int length = strlen(array); cout << length; hello\0???? [0][1][2][3][4][5][6][7][8][9]
strlen char array[10] = “Hello”; int length = strlen(array); cout << length; hello\0???? [0][1][2][3][4][5][6][7][8][9]
5
strcpy char source[10] = “Hey”; char target[10] = “Boy Howdy”; strcpy(target, source);
strcpy char source[10] = “Hey”; char target[10] = “Boy Howdy”; strcpy(target, source); hey\0?????? [0][1][2][3][4][5][6][7][8][9] source:
strcpy char source[10] = “Hey”; char target[10] = “Boy Howdy”; strcpy(target, source); hey\0?????? [0][1][2][3][4][5][6][7][8][9] source: Boy Howdy\0 [0][1][2][3][4][5][6][7][8][9] target:
strcpy char source[10] = “Hey”; char target[10] = “Boy Howdy”; strcpy(target, source); hey\0?????? [0][1][2][3][4][5][6][7][8][9] source: hey\0Howdy [0][1][2][3][4][5][6][7][8][9] target:
strcpy... strcpy(target, “Hi”); strcpy(target, “BurritoToppings”; Hi\0 Howdy [0][1][2][3][4][5][6][7][8][9] target:
strcpy... strcpy(target, “Hi”); strcpy(target, “BurritoToppings”; BurritoTop [0][1][2][3][4][5][6][7][8][9] target:
strcat char source[10] = “There”; char target[10] = “Hi”; strcat(target, source);
strcat char source[10] = “There”; char target[10] = “Hi”; strcat(target, source); There\0???? [0][1][2][3][4][5][6][7][8][9] source:
strcat char source[10] = “There”; char target[10] = “Hi”; strcat(target, source); There\0???? [0][1][2][3][4][5][6][7][8][9] source: Hi\0??????? [0][1][2][3][4][5][6][7][8][9] target:
strcat char source[10] = “There”; char target[10] = “Hi”; strcat(target, source); There\0???? [0][1][2][3][4][5][6][7][8][9] source: HiThere\0?? [0][1][2][3][4][5][6][7][8][9] target:
strcat... strcat(target, “!!”); strcat(target, “!”); HiThere\0?? [0][1][2][3][4][5][6][7][8][9] target:
strcat... strcat(target, “!!”); strcat(target, “!”); HiThere!!\0 [0][1][2][3][4][5][6][7][8][9] target:
strcat... strcat(target, “!!”); strcat(target, “!”); HiThere!!! [0][1][2][3][4][5][6][7][8][9] target:
strcmp char ntca1[20] = “bob”; char ntca2[20] = “bob”; char ntca3[20] = “Bob”; cout<<strcmp(ntca1, ntca2); cout<<strcmp(ntca1, ntca3); cout<<strcmp(ntca3, ntca1); cout<<strcmp(ntca1, “bobby”); if (!(strcmp(ntca1, ntca2)) cout<<”these strings are identical”<<endl; else cout<<”these strings are different”<<endl;
strcmp char ntca1[20] = “bob”; char ntca2[20] = “bob”; char ntca3[20] = “Bob”; cout<<strcmp(ntca1, ntca2); cout<<strcmp(ntca1, ntca3); cout<<strcmp(ntca3, ntca1); cout<<strcmp(ntca1, “bobby”); if (!(strcmp(ntca1, ntca2)) cout<<”these strings are identical”<<endl; else cout<<”these strings are different”<<endl;
strcmp char ntca1[20] = “bob”; char ntca2[20] = “bob”; char ntca3[20] = “Bob”; cout<<strcmp(ntca1, ntca2); // 0 cout<<strcmp(ntca1, ntca3); cout<<strcmp(ntca3, ntca1); cout<<strcmp(ntca1, “bobby”); if (!(strcmp(ntca1, ntca2)) cout<<”these strings are identical”<<endl; else cout<<”these strings are different”<<endl;
strcmp char ntca1[20] = “bob”; char ntca2[20] = “bob”; char ntca3[20] = “Bob”; cout<<strcmp(ntca1, ntca2); // 0 cout<<strcmp(ntca1, ntca3); cout<<strcmp(ntca3, ntca1); cout<<strcmp(ntca1, “bobby”); if (!(strcmp(ntca1, ntca2)) cout<<”these strings are identical”<<endl; else cout<<”these strings are different”<<endl;
strcmp char ntca1[20] = “bob”; char ntca2[20] = “bob”; char ntca3[20] = “Bob”; cout<<strcmp(ntca1, ntca2); // 0 cout<<strcmp(ntca1, ntca3); // 1 cout<<strcmp(ntca3, ntca1); cout<<strcmp(ntca1, “bobby”); if (!(strcmp(ntca1, ntca2)) cout<<”these strings are identical”<<endl; else cout<<”these strings are different”<<endl;
strcmp char ntca1[20] = “bob”; char ntca2[20] = “bob”; char ntca3[20] = “Bob”; cout<<strcmp(ntca1, ntca2); // 0 cout<<strcmp(ntca1, ntca3); // 1 cout<<strcmp(ntca3, ntca1); // -1 cout<<strcmp(ntca1, “bobby”); if (!(strcmp(ntca1, ntca2)) cout<<”these strings are identical”<<endl; else cout<<”these strings are different”<<endl;
strcmp char ntca1[20] = “bob”; char ntca2[20] = “bob”; char ntca3[20] = “Bob”; cout<<strcmp(ntca1, ntca2); // 0 cout<<strcmp(ntca1, ntca3); // 1 cout<<strcmp(ntca3, ntca1); // -1 cout<<strcmp(ntca1, “bobby”); if (!(strcmp(ntca1, ntca2)) cout<<”these strings are identical”<<endl; else cout<<”these strings are different”<<endl;
strcmp char ntca1[20] = “bob”; char ntca2[20] = “bob”; char ntca3[20] = “Bob”; cout<<strcmp(ntca1, ntca2); // 0 cout<<strcmp(ntca1, ntca3); // 1 cout<<strcmp(ntca3, ntca1); // -1 cout<<strcmp(ntca1, “bobby”); // -1 if (!(strcmp(ntca1, ntca2)) cout<<”these strings are identical”<<endl; else cout<<”these strings are different”<<endl;
strcmp char ntca1[20] = “bob”; char ntca2[20] = “bob”; char ntca3[20] = “Bob”; cout<<strcmp(ntca1, ntca2); // 0 cout<<strcmp(ntca1, ntca3); // 1 cout<<strcmp(ntca3, ntca1); // -1 cout<<strcmp(ntca1, “bobby”); // -1 if (!(strcmp(ntca1, ntca2)) cout<<”these strings are identical”<<endl; else cout<<”these strings are different”<<endl;
strcmp char ntca1[20] = “bob”; char ntca2[20] = “bob”; char ntca3[20] = “Bob”; cout<<strcmp(ntca1, ntca2); // 0 cout<<strcmp(ntca1, ntca3); // 1 cout<<strcmp(ntca3, ntca1); // -1 cout<<strcmp(ntca1, “bobby”); // -1 if (!(strcmp(ntca1, ntca2)) cout<<”these strings are identical”<<endl; else cout<<”these strings are different”<<endl;
strcmp char ntca1[20] = “bob”; char ntca2[20] = “bob”; char ntca3[20] = “Bob”; cout<<strcmp(ntca1, ntca2); // 0 cout<<strcmp(ntca1, ntca3); // 1 cout<<strcmp(ntca3, ntca1); // -1 cout<<strcmp(ntca1, “bobby”); // -1 if (!(strcmp(ntca1, ntca2)) cout<<”these strings are identical”<<endl; else cout<<”these strings are different”<<endl; Take Note!
Dangers char source[10] = “Walk This Way”; char target[15]; strcpy(target, source); strcat(target, source);
Also Available strncpy strncmp strncat
End of Session