Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

how can we store the value of dynamic char pointer into character array

0 votes
asked Dec 10, 2017 by anonymous

1 Answer

0 votes
answered Dec 30, 2017 by Eduardo Yánez (240 points)

Do you mean this?

#include <iostream>
#include <cstring>

using namespace std;

int main() {
    const char* c_str = "Hello world\n";
    char greetings[20];
    memcpy(greetings, c_str, strlen(c_str)+1);
    cout << greetings << endl;
    return 0;
}

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...