C strcpy = Unhandled exception: Access violation writing location 0x00000000

前端 未结 2 1365
没有蜡笔的小新
没有蜡笔的小新 2021-01-21 14:51

I have a problem with strcpy function. Using C. Main point of this simple code (below) is copying a string from a array to the array of pointers.

char string[20]         


        
2条回答
  •  终归单人心
    2021-01-21 15:30

    You need to initialize array_of_pointers :

    array_of_pointers[0] = malloc(strlen(string)+1);
    

    Or best:

    array_of_pointers[0] = strdup(string);
    

提交回复
热议问题