Code:int i = 0, j, index[i]; char first_name[999][22]; while(fscanf(data_file, "%s", first_name[i])) { i++; //welcome to C! :) = i + 1; index[i] = i; //you're building an index array at the same time? Good! } //i has just counted the number of names in the array, so it can be used: --i; //step it back one time for (j = 0; j < i; j++) { //start with 0 not 1 printf("%s, ", first_name[j]); }