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

C++ help

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: 18
Thread images: 1

File: Help.png (46KB, 910x457px) Image search: [Google]
Help.png
46KB, 910x457px
Hello. Could you tell me what I did wrong here please? Don't mind the 2 digit grade stuff I'll do it later.
>>
>>57527764
When you enter the first first mark, think about what you are actually typing: a 6, a 9, AND a \n (hitting enter). cin will read the numerical part (69) but the non-numerical part is left in the buffer. So your next getline immediately reads a \n and stops, returning an empty string.

cin.ignore() will ignore a character in the input buffer.
>>
you used c++
>>
>>57527993
what would you recommend then?
>>
>>57528254
C
>>
>>57528366
OP here fuck that shit nigga. We need to do this in C but its fucking retarded. Kill yourself nigga
>>
>>57528547
m8, just use scanf() instead of cin
and printf() instead of cout and it's the same thing

if you are so retarded why don't you try python?
>>
>>57527979
>cin.ignore()
Thanks that actually worked. I replaced the second cin with cin.ignore. I'll look more into why it worked. Thank you
>>
>>57528604
I don't like that shit. You have to declare value types and have to use & to allocate shit fuck it I nearly puked at the first CP lesson.
>>
You're doing a lot wrong desu family, but everyone does at the start. Looks like someone else helped you out, but if I can give some style advice:
>give variables meaningful names, e.g. student1Score, student2Score, nameQuestion, scoreQuestion, student1Name, student2Name
>even better, use arrays and a loop if you know how, though it looks like the course you're taking may not have covered those concepts yet
>in general, avoid multiple statements on one line (i.e. start a new line after each semicolon)
>you can put a '\n' character at the end of a string instead of doing it as a single character, e.g. "Student 1:\n"
>>
>>57528639
Just read & as "address of" and your good to go.
>>
>>57528806 again
Actually sorry I don't know why I said you're doing a lot wrong, that was mean. Hope you find the advice helpful though.
>>
>>57528806
>>57528834
No worries. Thanks for your consideration. Yes i know bout loops and arrays from highschool but it seemed easier for me to do it like this. I'm not at Computer Science so we don't do intensive programming like learning 4 different languages at the same time or whatever some of my friends do. I went for electrical engineering because I like it more than programming. I don't want to code for the rest of my life, I feel that even if I gave my best at programming there's always some code monkey 12yr old that would outrun me by miles and the fact that there's 12 billion languages which are constantly upgrading or whatever makes it even shittier for me.
Sorry for the blogpost. Thank you all for the help and sorry for the retarded nignog replies.
>>
>>57527764
You can replace '\n' with "endl".
Using system("pause") is a very bad practice since it doesn't work outside Windows and MS-DOS systems.
You can replace that with a prompt that says "Press ENTER to continue..." and cin.ignore(1,'\n');
>>
>>57529328
Dully noted
>>
>>57528254
C#
>>
For starters, system("pause") is always wrong. Remove it from your code.
>>
>>57529601
it's nice if you don't want to debug, but it gets annoying when you have to press enter everytimes. Just add a debug point
Thread posts: 18
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]

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.