code for copying two strings with out strcpy() function.

Answer Posted / ankitecian

int main(int argc, char *argv[])
{
char _output[200];
memset(_output,'\0',200);
if(argc < 2)
{
printf("Usage: <%s> <String -1>\n",argv[0]);
return -1;
}
StrCpy(_output,argv[1]);
printf("The Final String is::: \n[%s]\n",_output);
return 0;
}

int StrCpy(char *_output, const char *_input1)
{
int _cntr1 = 0;
while(*(_input1 + _cntr1) != NULL)
{
*(_output + _cntr1) = *(_input1 + _cntr1);
_cntr1++;
}
return 0;
}

Is This Answer Correct ?    1 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the 5 elements of structure?

560


What are the string functions? List some string functions available in c.

600


What is local and global variable in c?

613


What is a constant and types of constants in c?

598


What are actual arguments?

641






Apart from dennis ritchie who the other person who contributed in design of c language.

801


Is it cc or c in a letter?

558


What is conio h in c?

622


Which one would you prefer - a macro or a function?

598


What is class and object in c?

586


Why main is used in c?

583


How is null defined in c?

650


Do you have any idea about the use of "auto" keyword?

661


Is null always equal to 0(zero)?

578


Why is c called c?

620