I'm working a CS homework assignment.
But it requires loading data from a file in an array. Anyone want to help me as to how I can take data from a file, such as codes and prices for a vending machine, and then putting them into arrays and simulating a vending machine? Also using namespace std;
Forgot to mention it was C++
>>51508392
I had cs last semester and this assignment seems really familiar. Are you at ttu by any chance?
>>51508699
Nope, UTM.
Got any help to offer?
>>51508392
Isn't it about 2 months too late to being something this trivial?
Sounds fucking easy.
Make vector
Open file
Read each line and split on spaces, store each part in your object in your vector
When you get to the line that is defined as the last line by the spec, close the file
Literally babby tier.
>>51508699
I went to ttu if that's a Tennessee school
Make an array of sale items senpai, read through every line by splitting at the space and create objects and insert them into the array.
>>51508852
We haven't touched on vectors yet.
>>51508897
Well first off, I can't get the file to open. Using CodeBlocks and the file is saved on my computer. Gotta ignore the first line of the file, and then I don't know how to store the data that splits at the space into each array, without hard coding it.
>>51508950
you don't even need vectors
http://www.cplusplus.com/reference/cstdio/fread/
find some other people to do your hw
>>51509016
Thanks anon, but I'm assuming we can't use those examples because I've never seen them before.