char *ch = "abcde";
char c[4];
how to copy 'ch' to 'c'?
Answer Posted / parth ujenia
main()
{
char *ch="abcd";
char c[4];
for(int i=0;i<4;i++)
{
c[i]=*ch; //assign value to char c[i].
*ch++; //switch to next address of ch!
}
for(i=0; i<4 ;i++)
{
printf("%c - ",c[i]); //output will: a - b - c - d -
}
getch();
}
| Is This Answer Correct ? | 18 Yes | 7 No |
Post New Answer View All Answers
What is lazy initialization in c++?
Does std endl flush?
What is the best c++ book?
Can we define function inside main in c++?
How can you quickly find the number of elements stored in a dynamic array?
Define copy constructor.
Can we declare a base-class destructor as virtual?
How can an improvement in the quality of software be done by try/catch/throw?
What are files in c++?
What is a string example?
What are keywords in c++?
Why isn't sizeof for a struct equal to the sum of sizeof of each member?
How is computer programming useful in real life?
Explain the auto storage classes in c++.
Distinguish between new and malloc and delete and free().