-
work it out
ok i have a struct within a struct and am using linked lists,
e.g
struct subject
{
char onesubject [MAXNAME];
int num;
}
struct Result
{
long id;
subject students [MAXSUBJECTS];
}
do i use two pointers?
if so could you show me an example of how i could access data members of another struct within a struct.
Another question, what could i use to detect say ,J1234 detect the 1st number within the an array that contains those types of subject codes?
-
Well, let's see:
Say you have-
Result r;
So the first first student would be:
r.students[0]
and the first charachter of the subject of the first student would be:
r.students[0].onesubject[0];
Searching for the first digit of a subject would require a loop:
int i = 0;
const char* subject = r.students[0].onesubject;
const int length = strlen(subject);
for(;i<length;++i)
{
if(isdigit(subject[i])
{
break;
}
}