built-in functions for ntcas
DESCRIPTION
Built-in Functions for NTCAs. strlen. char array[10 ] = “Hello”; int length = strlen (array); coutTRANSCRIPT
![Page 1: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/1.jpg)
http://cs.mst.edu
Built-in Functions for NTCAs
![Page 2: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/2.jpg)
http://cs.mst.edu
strlen char array[10] = “Hello”; int length = strlen(array); cout << length;
![Page 3: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/3.jpg)
http://cs.mst.edu
strlen char array[10] = “Hello”; int length = strlen(array); cout << length;
h e l l o \0 ? ? ? ?
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
![Page 4: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/4.jpg)
http://cs.mst.edu
strlen char array[10] = “Hello”; int length = strlen(array); cout << length;
h e l l o \0 ? ? ? ?
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
![Page 5: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/5.jpg)
http://cs.mst.edu
5
![Page 6: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/6.jpg)
http://cs.mst.edu
strcpy char source[10] = “Hey”; char target[10] = “Boy Howdy”; strcpy(target, source);
![Page 7: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/7.jpg)
http://cs.mst.edu
strcpy char source[10] = “Hey”; char target[10] = “Boy Howdy”; strcpy(target, source);
h e y \0 ? ? ? ? ? ?
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
source:
![Page 8: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/8.jpg)
http://cs.mst.edu
strcpy char source[10] = “Hey”; char target[10] = “Boy Howdy”; strcpy(target, source);
h e y \0 ? ? ? ? ? ?
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
source:
B o y H o w d y \0
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
target:
![Page 9: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/9.jpg)
http://cs.mst.edu
strcpy char source[10] = “Hey”; char target[10] = “Boy Howdy”; strcpy(target, source);
h e y \0 ? ? ? ? ? ?
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
source:
h e y \0 H o w d y \0
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
target:
![Page 10: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/10.jpg)
http://cs.mst.edu
strcpy ... strcpy(target, “Hi”); strcpy(target, “BurritoToppings”;
H i \0 \0 H o w d y \0
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
target:
![Page 11: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/11.jpg)
http://cs.mst.edu
strcpy ... strcpy(target, “Hi”); strcpy(target, “BurritoToppings”;
B u r r i t o T o p
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
target:
![Page 12: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/12.jpg)
http://cs.mst.edu
strcat char source[10] = “There”; char target[10] = “Hi”; strcat(target, source);
![Page 13: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/13.jpg)
http://cs.mst.edu
strcat char source[10] = “There”; char target[10] = “Hi”; strcat(target, source);
T h e r e \0 ? ? ? ?
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
source:
![Page 14: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/14.jpg)
http://cs.mst.edu
strcat char source[10] = “There”; char target[10] = “Hi”; strcat(target, source);
T h e r e \0 ? ? ? ?
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
source:
H i \0 ? ? ? ? ? ? ?
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
target:
![Page 15: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/15.jpg)
http://cs.mst.edu
strcat char source[10] = “There”; char target[10] = “Hi”; strcat(target, source);
T h e r e \0 ? ? ? ?
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
source:
H i T h e r e \0 ? ?
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
target:
![Page 16: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/16.jpg)
http://cs.mst.edu
strcat ... strcat(target, “!!”); strcat(target, “!”);
H i T h e r e \0 ? ?
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
target:
![Page 17: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/17.jpg)
http://cs.mst.edu
strcat ... strcat(target, “!!”); strcat(target, “!”);
H i T h e r e ! ! \0
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
target:
![Page 18: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/18.jpg)
http://cs.mst.edu
strcat ... strcat(target, “!!”); strcat(target, “!”);
H i T h e r e ! ! !
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
target:
![Page 19: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/19.jpg)
http://cs.mst.edu
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;
![Page 20: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/20.jpg)
http://cs.mst.edu
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;
![Page 21: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/21.jpg)
http://cs.mst.edu
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;
![Page 22: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/22.jpg)
http://cs.mst.edu
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;
![Page 23: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/23.jpg)
http://cs.mst.edu
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;
![Page 24: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/24.jpg)
http://cs.mst.edu
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;
![Page 25: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/25.jpg)
http://cs.mst.edu
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;
![Page 26: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/26.jpg)
http://cs.mst.edu
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;
![Page 27: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/27.jpg)
http://cs.mst.edu
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;
![Page 28: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/28.jpg)
http://cs.mst.edu
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;
![Page 29: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/29.jpg)
http://cs.mst.edu
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!
![Page 30: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/30.jpg)
http://cs.mst.edu
Dangers char source[10] = “Walk This Way”; char target[15]; strcpy(target, source); strcat(target, source);
![Page 31: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/31.jpg)
http://cs.mst.edu
Also Available strncpy strncmp strncat
![Page 32: Built-in Functions for NTCAs](https://reader036.vdocuments.mx/reader036/viewer/2022062517/56813cd8550346895da67cb9/html5/thumbnails/32.jpg)
http://cs.mst.edu
End of Session