0

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

6
Contributors
7
Replies
8
Views
9 Years
Discussion Span
Last Post by Ancient Dragon
0

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.

0
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.
}
0
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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.