how to copy a string without using c 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 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between mpi and openmp?

738


What are structural members?

576


What is time null in c?

587


Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?

581


What are the standard predefined macros?

639






What is type qualifiers?

668


What is difference between structure and union in c?

551


What does %c mean in c?

656


What is array within structure?

589


What is file in c preprocessor?

656


What are qualifiers?

619


What is the value of a[3] if integer a[] = {5,4,3,2,1}?

677


Explain how can you tell whether two strings are the same?

587


What is static and volatile in c?

785


What is the purpose of 'register' keyword?

694