/* The aim of the program is to split the contents in e[i] and add them to the arrays name , surname and score. */ int main() { int entry,i,option; printf("\nPlease indicate the number of records you want to enter :\n"); scanf("%d",&entry); char ent[entry][100],name[entry][20],surname[entry][20],score[entry][10]; printf("\nPlease input records of students (enter a new line after each record), with following format first name last name score \n"); for (i=0; i<entry+1; i++) { gets(ent[i]); printf("%s",ent[i]); } for(i=0; i<entry+1; i++) { name[i] = strtok(ent[i]," "); <- Error printf("\n%s\n",name[i]); } printf("\nPlease choose the appropriate options :"); printf("\nPrint records (press 1)\nSearch by first name (press 2)\nSearch by last name (press 3)\nSort by score (press 4)\nSort by last name (press 5)\nExit the program (press 0)\n"); scanf("%d",&option); return 0; }
//Your for loops appear to be incorrect //Arrays are zero based, so the range is 0 to entry-1 for (i=0; i<entry;> { gets(ent[i]); printf("%s",ent[i]); } for(i=0; i<entry;> { name[i] = strtok(ent[i]," "); printf("\n%s\n",name[i]); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)