• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

Is there a C command that will copy over the contents of a string starting at x pos to the end of the string??

Or do I need to write my own. I can write my own, but it would be easier if I don't have to, you know what I am saying?  thank guys
0
kellyjj
Asked:
kellyjj
1 Solution
 
bernfarrCommented:
You can use strcpy(). The trick is to figure out the arguments you pass in.

char szTarget[12] = "MyName";

   strcpy( szTarget, "YourName" );  /* Straight replacement */

   /* Change MyName to MyNumber */
   strcpy( &(szTarget[3]), "umber" );

I don't know if this is exactly what you wanted, but it may give you a place to start.
0
 
kellyjjAuthor Commented:
That wasn't exactly what I wanted, but your answer clicked it for me. Thanks.


0
 
vipinjainCommented:
Hello Mr. Kellyji,

Here is another option that you can use for your need.
Ultimately You can use th STRNCPY() Function for this purpose.
e.g. : Suppose you have
 char a[]="amar nath panda";
 char b[15]; and You want to copy the string from 3rd pos. to  the end of the source string.

Sol : Use strncpy(b,3,a);
                printf("\n%s -- %s",a,b);
I think you would like it. Please send your comment at the following E-mail Address.
 amarnath_panda@wowmail.com
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now