Function. Use the built-in help for details.
strcat (into, from); correct. into (strcat, from); incorrect. strcat (from, from); incorrect. ....
strcat
The strcat() function has the following protocol:char* strcat (char* destination, char* source);The function appends the source string to the destination string and returns the destination string.The destination string must be a null-terminated character array of sufficient length to accommodate strlen (source) plus strlen (destination) characters, plus a null-terminator. The existing null-terminator and subsequent characters of destination are overwritten by characters from the source string, up to and including the source string's null-terminator.strcat (string, '!') will not work because '!' is a character literal (ASCII code 33 decimal), not a null-terminated character array. Use "!" instead of '!'.Example:char string[80]; // character arraystrcpy (string, "Hello world");strcat (string, "!");puts (string);
Language dependent. In C, for example, there no string as such, but you can use function strcat to concatenate zero-terminated character-sequences.
#include #include main() { char a[30],fs[50]="",t[3],sd,ed,x[3],s[3],d[3],y[3]; int i,j,p=0,q=0; clrscr(); printf("Enter characters to be stuffed : "); scanf("%s",a); printf("\nEnter a character that represents starting delimiter : "); scanf(" %c",&sd); printf("\nEnter a character that represents ending delimiter : "); scanf(" %c",&ed); x[0]=s[0]=s[1]=sd; x[1]=s[2]='\0'; y[0]=d[0]=d[1]=ed; d[2]=y[1]='\0'; strcat(fs,x); for(i=0;i { t[0]=a[i]; t[1]='\0'; if(t[0]==sd) strcat(fs,s); else if(t[0]==ed) strcat(fs,d); else strcat(fs,t); } strcat(fs,y); printf("\nAfter stuffing : %s",fs); getch(); }
strcat (into, from); correct. into (strcat, from); incorrect. strcat (from, from); incorrect. ....
#include <stdio.h> #include <stdlib.h> const char *noun[]={"boy", "girl", "dog", "town", "car"}; const char *verb[]={"drove", "jumped", "ran", "walked", "skipped"}; const char *preposition[]={"to", "from", "under", "over", "on"}; const char *article[]={"the", "a", "one", "some", "any"}; char sentence[50]; int main(void) { strcat(sentence, *(article+(rand() %5))); strcat(sentence, " "); strcat(sentence, *(noun+(rand() %5))); strcat(sentence, " "); strcat(sentence, *(verb+(rand() %5))); strcat(sentence, " "); strcat(sentence, *(preposition+(rand() %5))); strcat(sentence, " "); strcat(sentence, *(article+(rand() %5))); strcat(sentence, " "); strcat(sentence, *(noun+(rand() %5))); printf("%s",sentence); getch(); return 0; }
strcat if u wnt to use strcat then include string.h header file
strcat
strcat()
Using strcpy and strcat. Or sprintf. Or strlen+memcpy. There are more than solutions.
use strcat, strncpy, stpcpy, sprintf, strlen+memcpy, etc
The strcat() function has the following protocol:char* strcat (char* destination, char* source);The function appends the source string to the destination string and returns the destination string.The destination string must be a null-terminated character array of sufficient length to accommodate strlen (source) plus strlen (destination) characters, plus a null-terminator. The existing null-terminator and subsequent characters of destination are overwritten by characters from the source string, up to and including the source string's null-terminator.strcat (string, '!') will not work because '!' is a character literal (ASCII code 33 decimal), not a null-terminated character array. Use "!" instead of '!'.Example:char string[80]; // character arraystrcpy (string, "Hello world");strcat (string, "!");puts (string);
Language dependent. In C, for example, there no string as such, but you can use function strcat to concatenate zero-terminated character-sequences.
#include #include main() { char a[30],fs[50]="",t[3],sd,ed,x[3],s[3],d[3],y[3]; int i,j,p=0,q=0; clrscr(); printf("Enter characters to be stuffed : "); scanf("%s",a); printf("\nEnter a character that represents starting delimiter : "); scanf(" %c",&sd); printf("\nEnter a character that represents ending delimiter : "); scanf(" %c",&ed); x[0]=s[0]=s[1]=sd; x[1]=s[2]='\0'; y[0]=d[0]=d[1]=ed; d[2]=y[1]='\0'; strcat(fs,x); for(i=0;i { t[0]=a[i]; t[1]='\0'; if(t[0]==sd) strcat(fs,s); else if(t[0]==ed) strcat(fs,d); else strcat(fs,t); } strcat(fs,y); printf("\nAfter stuffing : %s",fs); getch(); }
Here is very small application written in C, that concatenates strings.#include #include int main() {char str[100];strcpy(str, "Hello ");strcat(str, "World!");printf("%s\n", str);return 0;}The result is "Hello World!".Concatenation is done by function strcat which is defined in string.h.
Win/Dos: copy file1+file2 tofile unix: cat file1 file2 >tofile