c - Array of pointers to char check for new string -


i have array of pointers chars store string console. how can check, if new string entered inkrement index? thought segmentation fault.

char** arr; int = 0; int j = 0;  arr = malloc(sizeof(char*) * 10);  while (arr[i][j] != '\n') {     scanf("%c", &arr[i][j]);     j++; } i++; // read next string here 

you allocating memory pointers. need make pointers point memory location before writing it.like

arr[i] = malloc(sizeof(char) *20); 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -