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 iostream in c++ used for?
Differentiate between an external iterator and an internal iterator? What is the advantage of an external iterator.
Write a program using display() function which takes two arguments.
Write a program which uses functions like strcmp(), strcpy()? etc
What is type of 'this' pointer? Explain when it is get created?
Is c++ a dying language?
What is the use of c++ programming language in real life?
What is java and c++?
What is the hardest coding language to learn?
Are there interfaces in c++?
When should I use unitbuf flag?
When the constructor of a base class calls a virtual function, why doesn't the override function of the derived class gets called?
When there is a global variable and local variable with the same name, how will you access the global variable?
Is c++ vector dynamic?
What is the use of data hiding?