[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Extra juicy! | Home]

I'm working a CS homework assignment. But it requires loading

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 11
Thread images: 1

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.
Thread posts: 11
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]
Please support this website by donating Bitcoins to 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
If a post contains copyrighted or illegal content, please click on that post's [Report] button and fill out a post removal request
All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site. This means that 4Archive shows an archive of their content. If you need information for a Poster - contact them.