[source code] C Programming Tutorial - 34 - strcat and strcpy

+4 Bucky Roberts · August 7, 2014



#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>


int main()
{
   char ham[100] = "Hey ";


   //strcat adds one string on to the end of another
   //make sure the original string is long enough to hold the additions
   strcat(ham, "Bucky ");
   strcat(ham, "you ");
   strcat(ham, "smell! ");
   printf("%s \n", ham);


   //strcpy replaces one string with another
   strcpy(ham, "Bucky is Awesome! ");
   printf("%s \n", ham);


   return 0;
}


Post a Reply

Replies

Oldest  Newest  Rating
+1 Hamza Ghandi · August 18, 2016
thanks Bucky but I have problem is that I want to run some other application (it's not about this source code)
rather than notepad to plot functions or manipulating images something like that
:)   
  • 1

C

124,708 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator