i have project and the time remaining to due is day and half and iam really stuck i would appreciate some help this is the project :
Write a menu driven program with the following options:
It opens and reads from a data file id’s and grade and name. The number of lines of input is unknown. It will store them in 3 parallel arrays (ids, grades, and names). Make the ids array of type long to handle large integer values.
Then it will show a menu of choices: Add a grade (reads the id, grade and corresponding name from the user). It will add the grade and name only if the id read does not exist already among the id’s present in the array.
Find a grade given an id i.e. your program will read the id from the user and find the corresponding grade.
Delete a user from the 3 arrays (id, grade, and name)
Sort the 3 arrays according to the id (in increasing order)
Sort the 3 arrays according to the grades from low to high
Sort the 3 arrays according to the grades from high to low. Finds the average
Saves the id’s and grades in the file.
Sort the 3 arrays according to names alphabetically (Bonus)
Practice modular programming by writing functions whenever possible. Follow the convention concerning variable names. Insert comments wherever needed.
this writing is strange we didnt used it in the course and we use dev c++ and sections is aray data file strings loops but i didnt see this ifstream f;
iam not fimliar with (ifstream) we didnt use it in the course so icant use it in the project is there another way of to store arrays and string in data file with no specific number for the data that will be entered
Given your assignment requirements you are going to need to use dynamic arrays, which these are not. (In fact, arrays without specified sizes are not legal in this context in C and never legal in C++.)
int id[80],grade[80] ;
char name[80];
for(i=0;fscanf(input," %s ",&name[i])!=EOF;i++){
printf(" %s ",&name[i]);
}
when i do it like that it works and the names comes as i put them in th file but when i do it like this
int id[80],grade[80] ;
char name[80];
for(i=0;fscanf(input,"%d %s",&id[i],&name[i])!=EOF;i++){
printf(" %d %s ",&id[i],&name[i]);
}
the id numbers that i entered do not come out instead comes numbers like that 2357849 but the names comes correct as i put them in the file so whats wrong ?
There's something about writing C code in Visual Studio that upsets me... I really don't like it... I'd rather use Sublime Text and Make on my Linux machine than write C in Visual Studio.