suppose there are two strings str1 and str2.
suppose i filled str1 with some characters.Now what i want to do is copying string str2 at some specified location in str1.
How can i do it?
To append to strings in C you use strcat. To copy from another string you use strcpy. (There are variants of these that allow you to specify a length - check your documentation).
It is unclear to me which you need. Below is an example that shows how to use both.
int main () {
char str1[32] = {};
char str2[32] = {};
/* Place data in str1 */
strcpy (str1, "abcdefghijklmnopqrstuvwxyz");
/* Copy from within str1 to str2 */
strcpy (str2, str1 + 5);
printf ("str1 : %s\n", str1);
printf ("str2 : %s\n", str2);
/* clear strings */
memset (str1, 0, 32);
memset (str2, 0, 32);
/* Place data in str1 */
strcpy (str1, "12345");
/* Place data in str2 */
strcpy (str2, "09876");
/* Append str2 to the end of str1 */
strcat (str1, str2);
printf ("str1 : %s\n", str1);
return 0;
}