am a new in c+= and i hve to do those two functins :
strcpy and atoi functin....if anyone can help plz reply
thanx alot

Recommended Answers

All 7 Replies

Member Avatar for iamthwee

Post your attempts.

Just copy the content of source array to destination array using a for loop.

bt how can u plz write me the code?

Did you search your school text book for those two functions? We are not here to write all the code for you but to help you write it yourself. If we write it you will learn nothing. Search around and you will find millions of examples of those two functions.

wrong forum. This is the C++ forum, not the C+= forum!

commented: Genius, pure genius! +13
char *  strcpy(char * to, char * from)
{
    char * temp=to; 
  
    while((*to++=*from++) != 0) {};
// what to is pointing to takes what from is 
// pointing to and the pointers move on.
// when end of string encountred (0) it stops
return temp;
// temp has the initial value of to in it so the
// copy can be cascaded.
}
char *  strcpy(char * to, char * from)
{
    char * temp=to; 
  
    while((*to++=*from++) != 0) {};
// what to is pointing to takes what from is 
// pointing to and the pointers move on.
// when end of string encountred (0) it stops
return temp;
// temp has the initial value of to in it so the
// copy can be cascaded.
}

Nice code and explaination, but doesn't solve the problem. Apparently the purpose of the exercise is to use the strcpy() function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.