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 sorting algorithm does c++ use?
Explain selection sorting?
Which software is best for coding?
What is a static element?
Explain virtual class?
What is c++ vb?
What are advantages of c++?
In inline " expression passed as argument are evalauated once " while in macro "in some cases expression passed as argument are evaluated more than once " --> i am not getting it plz help to make me understand....
What is searching? Explain linear and binary search.
What is scope resolution operator in c++ with example?
What is difference between c++ 11 and c++ 14?
In the derived class, which data member of the base class are visible?
Differentiate between late binding and early binding.
Why cstdlib is used in c++?
What are the operators in c++?