I am trying to learn multi-dimensional arrays in C/C++, but am not having much luck. I think I understand the way this type of array works, but I am having problems.
Does anyone know what is wrong in my code? There are no compilation errors, but the program crashes after the first name is entered.Code:#include <stdio.h> #include <stdlib.h> #define MAX_NAME_COUNT 10 #define MAX_NAME_LEN 100 int main(){ char *names[MAX_NAME_COUNT][MAX_NAME_LEN]; int x; printf("enter the names of 10 people:\n"); for(x = 1; x < MAX_NAME_COUNT; x++){ scanf("%s", names[x][0]); } printf("these are the names you entered are:\n"); for(x = 1; x < MAX_NAME_COUNT; x++){ printf("%s\n", names[x][0]); } return; }



LinkBack URL
About LinkBacks



