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 the basic structure of a c++ program?
Why is c++ is better than c?
Why are pointers used?
What are the basic data types used in c++?
Which header file allows file i/o with streams a) fileio.h b) iostream.h c) fstream.h
Write some differences between an external iterator and an internal iterator? Describe the advantage of an external iterator.
What is the meaning of string in c++?
What is a pointer with example?
Which is the best c++ compiler for beginners?
Why do you use the namespace feature?
What programming language should I learn first?
Why is main function important?
How can you quickly find the number of elements stored in a a) static array b) dynamic array ? Why is it difficult to store linked list in an array?how can you find the nodes with repetetive data in a linked list?
What is #include ctype h in c++?
Evaluate as true or false: !(1 &&0 || !1) a) True b) False c) Invalid statement