String append: Difference between revisions

Content added Content deleted
Line 41: Line 41:
</pre>
</pre>


=={{header|BASIC}}==
=={{header|C}}==
<lang C>#include<stdio.h>
==={{header|Applesoft BASIC}}===
//append a string
<lang BASIC>S$ = "Hello"
#include<string.h>
S$ = S$ + " World!"

PRINT S$</lang>
int main()
==={{header|BBC BASIC}}===
{
<lang BBC BASIC> S$="Hello"
S$+=" World!"
char str[]="Good Morning";
PRINT S$
char *cstr=" to all";
END</lang>
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;
}
</lang>
{{out}}
{{out}}
<pre>Hello World!</pre>
<pre>Good Morning to all !!!</pre>


=={{header|C++}}==
=={{header|C++}}==