samedi 20 août 2016

How To Assign char* to an Array variable

I have recently started to code in C and I am having quite a lot of fun with it. But I ran into a little problem that I have tried all the solutions I could think of but to no success. How can I assign a char* variable to an array?

Example

int main()
{
    char* sentence = "Hello World";

    //sentence gets altered...

    char words[] = sentence;

    //code logic here...

    return 0;
}

This of course gives me an error. Answer greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire