Anonymous user
String append: Difference between revisions
→{{header|C}}
Line 41:
</pre>
=={{header|
<lang C>#include<stdio.h>
//append a string
#include<string.h>
PRINT S$</lang>▼
int main()
{
char
char *cstr="
char *cstr2="
int x=0;
//run time 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;
}
{{out}}
<pre>
=={{header|C++}}==
|