• What are you working on? V2
    2,001 replies, posted
[QUOTE=nullsquared;16186117]The [b]proper[/b] way of doing it is: [code] std::cin.ignore(std::cin.rdbuf()->in_avail() + 1); [/code][/QUOTE] Oh yes how beautiful and advantageous in this situation. [editline]09:09AM[/editline] [QUOTE=Kat of Night;16186145]except don't use hungarian, use K&R bracketing: [code] if () { four column space indent; more portable and attractive to the eye while () { four more spaces } } else { indent here too }[/code][/QUOTE] No that shit is ugly
[QUOTE=nullsquared;16186117]The [b]proper[/b] way of doing it is: [code] std::cin.ignore(std::cin.rdbuf()->in_avail() + 1); [/code][/QUOTE] I had some problems with in_avail, namely returning 0 although I clearly wrote more than I took out of std::cin. Afaik it returns the characters available in the buffer, and the stream doesn't seem to necessarily get buffered completely. So I've come to use std::cin.ignore(std::numeric_limits<int>::max(), '\n');.
It almost works like a charm, but, it won't [b]break[/b] out if you say something other than 1, after "winning". How would one go about this? [cpp] #include <iostream> //Welcome to the jungle, babe. //numbers - Klownox int main() { while(true) { int a; int b; int c; std::cout << "\nPlease enter a number from 0-100: "; std::cin >> a; if (a > 100, a < 0) { continue; } else { std::cout << "\nThank you, now please get your friend to guess you number: "; std::cin >> b; } if (b == a){ std::cout << "\nYou have guessed the correct number! Play again(1 = Yes)? "; std::cin >> c; if (c == 1) { continue; } else { break; } } else { std::cout << "\nYou have not guessed the correct number, try again: "; std::cin >> b; continue; } } return 0; } [/cpp] And, I prefer finding things out from people rather than a tutorial/book. [b]Edit:[/b] If possible, how would I do [b]Y/N[/b] for "Playing Again" rather than 1 and != 1? [b]Edit 2:[/b] Fixed the [b]not-breaking[/b] error. Is there a way to do Y/N?
Take a look at line 30 Klownox, notice anything?
Yeah, I fixed that. == [editline]09:44PM[/editline] Yes, multi-player is finished <3 [cpp] #include <iostream> //Welcome to the jungle, babe. //numbers - Klownox int main() { while(true) { int a; int b; int c; int Y; int N; Y = 1; N != 1; std::cout << "\nPlease enter a number from 0-100: "; std::cin >> a; if (a > 100, a < 0) { continue; } else { std::cout << "\nThank you, now please get your friend to guess your number: "; std::cin >> b; } if (b == a){ std::cout << "\nYou have guessed the correct number! Play again? (Y/N) "; std::cin >> c; if (c == Y) { continue; } else { break; } } else { std::cout << "\nYou have not guessed the correct number, try again: "; std::cin >> b; continue; } } return 0; } [/cpp]
I feel like i am slowly getting better at coding C# now which is great! =) Map changing! [media]http://www.youtube.com/watch?v=XJ_lft2JkcU[/media]
Nice, JimmyLaw
[QUOTE=HubmaN V2;16176621]I just gave up on getting Ogre3D to play nice with Code::Blocks. Holy fucking goddamn, their Wiki is ancient. Time to reboot and see if it works with VC++, I suppose :( Their documentation and tutorials are top-notch, which make it much more frustrating.[/QUOTE] Stop following the setup tutorials. They're all bad. It's a simple process in any IDE: Step 1) Create a new console project Step 2) Add ogre's include directories ( remember to also add the sample app directories if you're using the sample framework ) Step 3) Add lib directories. Step 4) Add libs to linker list thingo. Step 5) Build and Run. ( Also if using sample app framework you probably will need to fiddle around and put the media where it can find it ) Or if you're using MonoDevelop: Step 1) Create a new C++ console application. Step 2) Right click on Packages, select Edit Packages. Step 3) Scroll down and check the box which says OGRE, then click OK. Step 4) Build and Run.
It won't work with selecting Single/Multiplayer. Should I do this in 2 separate files, or am I just stupid? [cpp] #include <iostream> //Welcome to the jungle, babe. //numbers - Klownox int main() { int a; int S; int M; S = 1; M != 1; std::cout << "Do you want to play Singleplayer or Multiplayer?(S/M): "; std::cin >> a; if (a == S) { while(true) { int a; int b; int c; int Y; int N; Y = 1; N != 1; srand(static_cast<int>(time(NULL))); std::cout << "Generating a random number from 0-100. . ."; a == rand() % 100; std::cout << "\n" << "\n" << "Please guess a number from 0-100: "; std::cin >> b; if (b == a) { std::cout << "\nYou have guessed the correct number! Play again? (Y/N) "; std::cin >> c; if (c == Y) { continue; } else { break; } } else { std::cout << "\nYou have not guessed the correct number, try again: "; std::cin >> b; continue; } } } else { while(true) { int a; int b; int c; int Y; int N; Y = 1; N != 1; std::cout << "\nPlease enter a number from 0-100: "; std::cin >> a; if (a > 100, a < 0) { continue; } else { std::cout << "\nThank you, now please get your friend to guess your number: "; std::cin >> b; } if (b == a) { std::cout << "\nYou have guessed the correct number! Play again? (Y/N) "; std::cin >> c; if (c == Y) { continue; } else { break; } } else { std::cout << "\nYou have not guessed the correct number, try again: "; std::cin >> b; continue; } } } } [/cpp]
[QUOTE=Jimmylaw;16186802]I feel like i am slowly getting better at coding C# now which is great! =) Map changing! [media]http://www.youtube.com/watch?v=XJ_lft2JkcU[/media][/QUOTE] You're really improving! I really do like the way your program looks, and that little sprite guy is so lovable!
err.. you need to use a char, right now you're checking if it's one, not S
[QUOTE=ZeekyHBomb;16185764][url]http://xkcd.com/292/[/url] Tis true, you know? Read up on loops, goto indicates a flaw in your design; [b]you should never use that.[/b] Also, you should say that the maximal integer-value should be 100. [editline]2:47AM[/editline] Also, try to indent your code right, meaning one tab (or an amount of spaces) when a new scope begins, and one less when it ends.[/QUOTE] Guess no one should ever use a function, if statement, or the linux kernel then. Because that's what they are. In fact the Linux kernel uses them extensively. goto's are JUST fine, and is how everything looks when it gets compiled down to assembly ANYWAYS. But because some asshole said "You know what, goto's are fucking stupid", and it got taught in fucking colleges (which are NOT the pinnacle of computer science), it has become commonly thought that goto's are evil and only idiots use them.
[QUOTE=Chandler;16190122]Guess no one should ever use a function, if statement, or the linux kernel then. Because that's what they are. In fact the Linux kernel uses them extensively. goto's are JUST fine, and is how everything looks when it gets compiled down to assembly ANYWAYS. But because some asshole said "You know what, goto's are fucking stupid", and it got taught in fucking colleges (which are NOT the pinnacle of computer science), it has become commonly thought that goto's are evil and only idiots use them.[/QUOTE] omg [editline]01:37PM[/editline] Not even going to bother
[QUOTE=Chandler;16190122]Guess no one should ever use a function, if statement, or the linux kernel then. Because that's what they are. In fact the Linux kernel uses them extensively. goto's are JUST fine, and is how everything looks when it gets compiled down to assembly ANYWAYS. But because some asshole said "You know what, goto's are fucking stupid", and it got taught in fucking colleges (which are NOT the pinnacle of computer science), it has become commonly thought that goto's are evil and only idiots use them.[/QUOTE] [img]http://www.facepunch.com/fp/emoot/ughh.gif[/img]
[QUOTE=Chandler;16190122]Guess no one should ever use a function, if statement, or the linux kernel then. Because that's what they are. In fact the Linux kernel uses them extensively. goto's are JUST fine, and is how everything looks when it gets compiled down to assembly ANYWAYS. But because some asshole said "You know what, goto's are fucking stupid", and it got taught in fucking colleges (which are NOT the pinnacle of computer science), it has become commonly thought that goto's are evil and only idiots use them.[/QUOTE] [img]http://www.facepunch.com/fp/emoot/ughh.gif[/img] You tried...
[QUOTE=Chandler;16190122]Guess no one should ever use a function, if statement, or the linux kernel then. Because that's what they are. In fact the Linux kernel uses them extensively. goto's are JUST fine, and is how everything looks when it gets compiled down to assembly ANYWAYS. But because some asshole said "You know what, goto's are fucking stupid", and it got taught in fucking colleges (which are NOT the pinnacle of computer science), it has become commonly thought that goto's are evil and only idiots use them.[/QUOTE] Since no one else is saying it. A GOTO isn't bad you're right. It is bad programmers that don't know how to USE the goto's. And 90% of the people who START OFF FRESH in trying to learn programming get a tutorial that says to use them and then that new programmer decides to use them in their new project. The problem is, is in this next project where they don't have someone holding their hand, they end up doing it wrong and that is where the problem is.
[QUOTE=Squad;16191161]Since no one else is saying it. A GOTO isn't bad your right. It is bad programmers that don't know how to USE the goto's. And 90% of the people who START OFF FRESH in trying to learn programming get a tutorial that says to use them and then that new programmer decides to use them in their new project. The problem is, is in this next project where they don't have someone holding their hand, they end up doing it wrong and that is where the problem is.[/QUOTE] We're not talking about a programmer's skill. Yes, I agree with you. But saying a goto is evil is just ignorant. You guys who facepalmed me are going to hate assembly, or python, if you ever use it.
[QUOTE=Chandler;16191337]We're not talking about a programmer's skill. Yes, I agree with you. But saying a goto is evil is just ignorant. You guys who facepalmed me are going to hate assembly, or python, if you ever use it.[/QUOTE] I am going to have to disagree. That person who posted the code looked like they were of amateur nature, so usually people use GOTO incorrectly. But I don't know. That was always my understanding of the matter though. And a lot of people in here have done assembly and more have done python.
I'm thinking about using XNA over C++, I was wondering how you guys felt about XNA and how much different C# is from C++. Help would really be appreciated, thanks guys.
[QUOTE=Squad;16191161]Since no one else is saying it. A GOTO isn't bad [highlight]you're[/highlight] right. It is bad programmers that don't know how to USE the goto's. And 90% of the people who START OFF FRESH in trying to learn programming get a tutorial that says to use them and then that new programmer decides to use them in their new project. The problem is, is in this next project where they don't have someone holding their hand, they end up doing it wrong and that is where the problem is.[/QUOTE] Which tutorials use goto? Anyway, [B]you're[/B] right. There's a good chance a beginner will just confuse himself and has no idea what the program does after a few gotos.
[QUOTE=Squad;16191505]I am going to have to disagree. That person who posted the code looked like they were of amateur nature, so usually people use GOTO incorrectly. But I don't know. That was always my understanding of the matter though. And a lot of people in here have done assembly and more have done python.[/QUOTE] I'm not disagreeing saying that he SHOULD use a goto. I'm just saying that to see a goto and instantly begin frothing at the mouth is stupid. Which is better for recursion? Calling a separate function that calls back to the one you are currently in? or using a goto? Why use classes at all? You're using a label. public: private: protected: in python why use a function ever? [code] def functionName(): [/code] Looks like a label to me. Assembly (usually) uses the JMP command to [b]go to[/b] a label.
[QUOTE=Chandler;16191625]Assembly (usually) uses the JMP command to [b]go to[/b] a label.[/QUOTE] But this isn't assembly.
[QUOTE=danharibo;16191716]But this isn't assembly.[/QUOTE] If you read my previous posts you would see I mentioned assembly as well as python. At this point you're nitpicking to hop onto the bandwagon. AREN'T YOU POPULAR :v:
[QUOTE=Chandler;16191842]If you read my previous posts you would see I mentioned assembly as well as python. At this point you're nitpicking to hop onto the bandwagon. AREN'T YOU POPULAR :v:[/QUOTE] No I'm reading your posts.
Chandler has no perspective at all.
You're stupid Chandler. Goto has its uses, but so does everything. It's still generally abused, it's still generally not recommended in high level languages. And just because you make use of a feature in one language does not make it a good idea in another.
[QUOTE=blankthemuffin;16191926]You're stupid Chandler. Goto has its uses, but so does everything. It's still generally abused, it's still generally not recommended in high level languages. And just because you make use of a feature in one language does not make it a good idea in another.[/QUOTE] Thanks for agreeing with me. No seriously. This is the point I've been trying to get across. I'm not saying goto is the end all be all solution. It has its uses. Am I saying to use ONLY goto's? No. Just don't think that because someone says "GOTOS ARE EVIL" that it's true. You guys don't believe the bullshit on Fox News (I assume), so why take everything you're told at face value. But then again it's like I'm talking to a conservative in the south, so the chances of you guys changing your opinion is the same as me losing my virginity in the next few weeks. (Slim to None, for those not counting). As such I'm done discussing this subject.
[QUOTE=Chandler;16192077]As such I'm done discussing this subject.[/QUOTE] That's good, because you're completely missing the whole point everyone is trying to make.
[QUOTE=Robber;16191616]Which tutorials use goto? Anyway, [B]you're[/B] right. There's a good chance a beginner will just confuse himself and has no idea what the program does after a few gotos.[/QUOTE] Sorry, I was playing poker and talking to someone when I was typing up that post. I was being distracted and trying to hurry so I didn't have time to think out my grammar. But I appreciate you figuring it out for me.
[QUOTE=Chandler;16190122]Guess no one should ever use a function, if statement, or the linux kernel then. Because that's what they are. In fact the Linux kernel uses them extensively. goto's are JUST fine, and is how everything looks when it gets compiled down to assembly ANYWAYS. But because some asshole said "You know what, goto's are fucking stupid", and it got taught in fucking colleges (which are NOT the pinnacle of computer science), it has become commonly thought that goto's are evil and only idiots use them.[/QUOTE] You can get around goto with usual loops or you are using it in stupid places. Gotos are stupid fucks to find and usually lead to avoidable and less readable code. Just because C++ gets compiled to assembly doesn't mean you have to write assembly. What's the point of the language then? There might be exceptions - that prove the rule - but you can usually get around it. [QUOTE=Chandler;16191625]in python why use a function ever? [code] def functionName(): [/code] Looks like a label to me. Assembly (usually) uses the JMP command to [b]go to[/b] a label.[/QUOTE] Moar liek call & ret.
Sorry, you need to Log In to post a reply to this thread.