char *ch = "abcde";
char c[4];
how to copy 'ch' to 'c'?

Answer Posted / gopi

main()
{
char *ch="abcd";
char c[4];

for(int i=0;i<4;i++)
{
c[i]=*ch;
ch++;
}


printf("%s",c);

getch();

}

Is This Answer Correct ?    12 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Search for: what is pair in c++?

586


Why do we use classes in programming?

568


What is the use of default constructor?

567


Can union be self referenced?

569


What are the types of array in c++?

616






What is a wchar_t in c++?

579


How many types of classes are there in c++?

590


What is copy constructor? Can we make copy constructor private in c++?

589


Can manipulators fall in love?

559


What are the advantages of c++? Explain

590


Who invented turbo c++?

603


What is void pointer in c++ with example?

590


What are the two types of comments?

570


Do you know what are static and dynamic type checking?

612


Is atoi safe?

589