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
How many namespaces are there in c++?
What is a character in c++?
What is c++ flowchart?
How long it will take to learn c++?
What is an accessor in c++?
Differentiate between a constructor and a destructor in c++.
Difference between a homogeneous and a heterogeneous container
what is the difference between overloading & overriding? give example.
Do you know what are pure virtual functions?
How do you master coding?
When must you use a pointer rather than a reference?
What is the main use of c++?
What sorting algorithm does c++ use?
Do vectors start at 0?
How can I improve my c++ skills?