[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 | Free Show | Home]

I'm new to c++ programming and I don't understand array

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: 15
Thread images: 2

File: tfwbrainlet.png (25KB, 837x391px) Image search: [Google]
tfwbrainlet.png
25KB, 837x391px
I'm new to c++ programming and I don't understand array coding. I'm not familiar with placing words into arrays.
>>
It might be better to ask on /g/ if you haven't, but what don't you understand exactly?
>>
Post your current progress if you want the good kind of help - as opposed to someone doing it all for you. To declare a string array, just do

string colors[5]

and then directly insert each string as it's provided to you.
>>
void man()
int size, i, arr[Max]
int*ptr;
ptr = &arr[0]
cout<<"Enter size of array";
scanf("%d",&size)

ans that's all so far. The next step for me is to enter the different strings. I don't know how to store words in arrays. I have only done numbers.
>>
>>371937
>>371937
No offense but this reads like bait. Who the hell taught you to do void man?

If you can't Google for help now, you won't get very far. The first step is learning how arrays work and how to make your own. You can do it with any data type, not just integers.
>>
>>371948
It's obviously a typo on "main()"
>>
>>372114
The void part is the issue.
>>
>>372124
It's obviously being called from a framework.

Even if it's not, void casts to int.
>>
>>372130
Nice assumptions bro
>>
>>372171
>>371948
likewise.
>>
File: program modified.png (36KB, 483x523px) Image search: [Google]
program modified.png
36KB, 483x523px
>>371948
Fixed my problem
It works. The only thing left to do is to limit the amount of colors I can enter
>>
>>372428
For that you'd simply do a check after line 17. If the number is greater than 10000, just set amount to 10000 and possibly alert the user of this via cout. But if this is being tested automatically, maybe they just want to enter 10001 and see only 10000 entries, in which case just silently cap the amount.
>>
>>372524
>silently cap the amount
What?
>>
>>372553
Don't print out anything to the user about it.
>>
>>372568
It's ok now.I got my program to work.
I used your first option.
I re set the amount to zero every time the number is greater than 1000 and give an error message
Thread posts: 15
Thread images: 2


[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]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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 RandomArchive shows their content, archived.
If you need information for a Poster - contact them.