[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
I'm working a CS homework assignment. But it requires loading
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 11
Thread images: 1
File: Screenshot_2015-11-24-12-31-16.png (290 KB, 1080x1920) Image search: [Google]
Screenshot_2015-11-24-12-31-16.png
290 KB, 1080x1920
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 replies: 11
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.