![]() |
|
#1
|
|||
|
|||
help on comparing structsHi,
I've got a problem where I can't check a slot in an array of struct to see if it's empty. I believe the following code would be legal in JAVA but I dunno why it isn't in C. Here's a snippet of my code. Any help appreciated. CPP / C++ / C Code:
|
|
#2
|
||||
|
||||
|
You're getting an error because bg doesn't exist in the context that you referenced it with. You must access members of a structure using dot notation, like so:
CPP / C++ / C Code:
CPP / C++ / C Code:
__________________
-Aaron |
|
#3
|
|||
|
|||
|
Hi aaroncohn,
hm..i don't think my code was clear enough. i'll be more specific i have a struct called proc, bg is an array of proc (proc bg[20]; ). newP is declared as a proc and I put some stuff into newP. Now, I want to find an empty slot to dump newP into array bg. So there;s no such thing as newP.bg[i] The main problem I have is how to check if a slot in a struct array is empty (NULL)? So the code is now: CPP / C++ / C Code:
|
|
#4
|
||||
|
||||
|
You cannot perform aggregate comparisons on structured types. You would have to compare each member of the array element to NULL, then if they were all NULL, you dump newP, but aggregate comparison of a struct type to anything is not allowed. Also, for future reference, when you're referring to an array, you use the plural form of the word. IE... an array of structs. When you said "an array of struct" in your comment, I took that to mean that it was a member of the struct called newP.
Code:
__________________
-Aaron |
|
#5
|
|||
|
|||
|
Hi aaroncohn,
Thanks, for the tip. |
Recent GIDBlog
Stupid Management Policies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Comparing Text Files (new programmer) | Trust | C++ Forum | 2 | 29-Mar-2004 10:14 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The