Thank you! Seeing that made that much "click" in as far as I can recreate that pretty consistently now on intuition, even if I'm not quite sure why the rules regarding array brackets feel so arbitrary. If I'm trying to call variables from the structured header file, how do I cite the structure?
i.e. Assuming the same header files in my OP, am I supposed to be doing this loop without array brackets (still doesn't work that way) or do I have to come up with a completely different salesType variable to call salesType variables?
1 2 3 4 5 6 7 8 9 10
|
void calcsales(ifstream & salesf, ofstream & outfile, salesType salesdata[], productType productdata[]) {
do {
salesf >> salesdata[].firstname >> salesdata[].lastname >> salesdata[].id;
//"firstname", "lastname", and "id" are all variables stored in the structure header file that salesdata[] is named for
while (productdata[].productnum!=-1 || salesdata[].numsales!=-1) {
salesf >> productdata[].productnum >> salesdata[].numsales;
}
//"numsales" is a salesdata[] structured variable and "productnum" is a productdata[] structured variable
} while (salesf);
}
|
And what if I want to cout that data? Do I still use type.variable syntax or do other rules apply?
Lastly, it compiles if I replace the dots with "->" and removes the array brackets, but I honestly don't know if it's referencing the data the same way with that method or not. It's not outputting anything at all when I run it with test cout statements. Also seems to undermine the entire array when I can't call it at all without losing the brackets, and by extension, the "array" part of the array.
And how do I call arrays by reference? Everything I've tried doesn't work but nothing I've found has said that it can't be done at all.