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

On throwing an exception by the animal constructor in p = new animalq, can memory leak occur?

677


What are static and dynamic type checking?

606


What is a vector c++?

547


Why c++ is so important?

602


What is virtual destructor ans explain its use?

599






What is the role of copy constructor in copying of thrown objects?

593


What is c++ best used for?

563


If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?

998


What is a .h file c++?

528


How is objective c different from c++?

788


What is difference between c++ and c ++ 14?

570


What is the full name of logo?

582


What is a list c++?

570


What is a syntax in c++?

603


What is the best book for c++ beginners?

566