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

What are the advantages of c++ over c?

795


Keyword mean in declaration?

777


What is c++ similar to?

814


What is the difference between the compiler and the preprocessor?

827


program explaining feautures of c++

2144






Why do we need function?

769


Why do you use the namespace feature?

849


What is ios flag in c++?

859


What is #include iostream in c++?

762


What is the use of endl in c++ give an example?

858


Write a program to show polymorphism in C++?

816


Is c++ proprietary?

791


Mention the purpose of istream class?

804


What is std namespace in c++?

884


Write a program to concatenate two strings.

767