I am sure it's pretty obvious, but I haven't been able to figure this out for a couple hours. I need to take input (words, strings) from the user and store it in the array, and then I need to access these elements by their index or something similar.
I've tried both frets and scanf but couldn't make it work.
Here's what I have so far:
typedef struct
{
char components[MAX_STRING];
int numComp;
char weightingSheme[MAX_STRING][50];
int numOfSchemes;
} CourseComponents;
char input [MAX_STRING]
CourseComponents newCourses;
int *Comp = &newCourses.numComp;
*Comp = 0;
int *numOfSchemes = &newCourses.numOfSchemes;
*numOfSchemes = 0;
for (i=0;i<newCourses.numComp;i++)
{
printf("Enter next component name: ");
scanf("%s", input);
strcpy(&newCourses.components[i], input);
}
newCourses.components[i], is it an array char or an array of pointers?char components[MAX_STRING][50];will not solve your problem?