String append: Difference between revisions
Content added Content deleted
Line 41: | Line 41: | ||
</pre> |
</pre> |
||
=={{header| |
=={{header|C}}== |
||
<lang C>#include<stdio.h> |
|||
==={{header|Applesoft BASIC}}=== |
|||
//append a string |
|||
<lang BASIC>S$ = "Hello" |
|||
#include<string.h> |
|||
S$ = S$ + " World!" |
|||
⚫ | |||
int main() |
|||
==={{header|BBC BASIC}}=== |
|||
{ |
|||
<lang BBC BASIC> S$="Hello" |
|||
char str[]="Good Morning"; |
|||
char *cstr=" to all"; |
|||
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}} |
{{out}} |
||
<pre> |
<pre>Good Morning to all !!!</pre> |
||
=={{header|C++}}== |
=={{header|C++}}== |