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 a type library?
How can you link a c++ program to c functions?
Why is c++ so fast?
Am studying basic c++ programming, have been given the following assignment. Design a linear program to calculate the maximum stress a material can withstand given a force and a diameter of a circle. To find the required area pi should be defined. Have most of the program sorted out but am at a loss as to how to show the calculations required. Can anyone help?
Which c++ compiler is best?
Are iterators pointers?
Explain unexpected() function?
How do I use turbo c++?
What is constant in c++ with example?
What are the various situations where a copy constructor is invoked?
Why do we use string in c++?
What is null pointer and void pointer and what is their use?
What is a buffer c++?
What is private, public and protected inheritance?
Write a function to perform the substraction of two numbers. Eg: char N1="123", N2="478", N3=-355(N1-N2).