String append: Difference between revisions

no edit summary
(Undo revision 188052 by Radhagupta (talk))
No edit summary
Line 53:
{{out}}
<pre>Hello World!</pre>
 
=={{header|C}}==
<lang c>#include<stdio.h>
#include<string.h>
 
int main()
{
char str[]="Good Morning";
char *cstr=" to all";
char *cstr2=" !!!";
int x=0;
//failure when space allocated to str is insufficient.
/* 1st method*/
strcat(str,cstr);
 
/*2nd method*/
x=strlen(str);
sprintf(&str[x],"%s",cstr2);
 
printf("%s\n",str);
return 0;
}</lang>
{{out}}
<pre>Good Morning to all !!!</pre>
 
=={{header|C++}}==