Hello, I am a first year student. I use gcc/netbeans to work with c. I have made a global structure then am trying to create another of that type that is an array.
i am trying to fill the array->charname[] inside of a switch statement. I have tried all the reference material available to me and am lost and tied. I have totaly swithced directions and am considering using a function instead of switch, but fear I am over complicating a simple task. I hope this isn't rude, please forgive,
here is my noodle mess:
Code:/* 9B * File: main.c * Author: Clay * * Created on November 13, 2011, 7:29 PM */ #include <stdio.h> #include <stdlib.h> #define MNAME 30 #define MSTUD 50 #define MGRADE 4 struct NameGrade // Global structure NameGrade { char name[MNAME]; int grade; struct NameGrade *nextstud; }; int main() { //Variables char choice, entkey, cont; int tempG, i, ct; char tempN[MNAME]; struct NameGrade Student[MSTUD]; typedef struct Student STU; //ASK user for input printf("Enter your desired action below:\n" "A to create a linked list of names and grades.\n" "B to add a new student to the list.\n" "C to modify a student in the list\n" "D to delete a student from the list.\n" "E to display the list.\n" "F to EXIT this program.\n"); scanf("%c", &choice);//USER enters choice from list //switch to execute USERS choice temp disabled till I fix STU.name //switch (choice) //{Create an initial linked list of students and grades // case 'A': // case 'a': if(choice == "a"||"A") //this IF is temporary till I figure //out why it isn't taking name while(cont != 'n' || 'N'); { i = 0; printf("Enter Name: "); scanf("%s", &tempN); Student->name[i] = tempN[i]; printf("Enter a grade for %s.\n", Student->name[i]); scanf("%d", &tempG); printf("Continue entering names and grades?\n" "Y for yes\n" "N for no\n"); scanf("%c", &cont); i++; } /* break; I have stopped here obviously*************** //Insert a new student into the list case 'B': case 'b': // break; //Modify an existing student in the list case 'C': case 'c': // break; //delete an existing student from linked list case 'D': case 'd': // break; //Display the linked list done? case 'E': case 'e': //ct = 0;used to count list entries for(i = 0; STU[i] != '\0'; i++) //ct++; printf(STU[i]); break; //EXIT from the program case 'F': case 'f': // exit; break; */ return(0); }