char *ch = "abcde";
char c[4];
how to copy 'ch' to 'c'?

Answer Posted / wade stone

#include <stdio.h>
#include <string.h>

using namespace std;

int main( )
{
char *ch = "abcde";
char c[4];

memcpy( c, ch, sizeof( c ) );

return 0;
}

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is c++ still being used?

766


What is a sequence in c++?

759


What is the rule of three?

762


What is fixed in c++?

759


What is anonymous object in c++?

837


Explain what you mean by a pointer.

849


Why do we learn c++?

727


What is & in c++ function?

786


What are c++ tokens?

798


Distinguish between a # include and #define.

854


What is else if syntax?

877


Describe the syntax of single inheritance in C++?

842


What is std :: flush?

802


What is dynamic and static typing?

878


How does c++ sort work?

750