I'm having a problem figuring out how to read the information from a text file and populate an array of structs using a pointer. My file and struct has 3 parts: account number, account name, and the amount in that account. I'm getting an error I don't know how to fix. This really should be easy, but I'm just missing it somewhere. I greatly appreciate any help, tips, or comments!
error: Line 59: invalid types 'budget [budget*]' for array subscrpt
If the last error you are using . notation on a pointer. To access the object pointed to you need ptr->. Or (*ptr).
*ptr = getline(inFile, ary[ptr]); //Line 59
Is incorrect because you used a pointer in . This should be a number for the index you wish to access.
And when you fix that problem you will have another. You're using a function that gets a std::string from a stream. But you put in one of your budgets in the function where the string should be.
Your use of getline is not what that function is for, and the arguments don't match, you can't do what your trying to do with getline. You need to get a std::string using getline, then parse the string yourself.