Advertisement
thenewboston

C Programming Tutorial - 34 - strcat and strcpy

Aug 22nd, 2014
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5.  
  6. int main()
  7. {
  8.     char ham[100] = "Hey ";
  9.  
  10.     //strcat adds one string on to the end of another
  11.     //make sure the original string is long enough to hold the additions
  12.     strcat(ham, "Bucky ");
  13.     strcat(ham, "you ");
  14.     strcat(ham, "smell! ");
  15.     printf("%s \n", ham);
  16.  
  17.     //strcpy replaces one string with another
  18.     strcpy(ham, "Bucky is Awesome! ");
  19.     printf("%s \n", ham);
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement