If Inside an If

Started by
17 comments, last by SSJGaz 20 years, 8 months ago
Just for future references; all controll structures can be nested ( placed inside one another ).. well in C/C++ anyways
/Please excuse my bad spelling - My native language is binary not english|Visit meTake my advice - I don''t use it...
Advertisement
That just compares the first letter of the char array. If you want to compare as a string:
#include <string>cin >> &buybasicsystem[0];if( strcmp(buybasicsystem, "y") == 0 )	cout <<"Test" << endl; 
Just a suggestion, Sleep() is annoying. Don''t use it for fancy purpores.

Let me tell you a true story:
A kid was making a game. When you start the game, you have to look at the title screen for about 5 WHOLE SECONDS!!!

Now, you see, I asked him, "Why do that?". He replied, "Because I wanted people to see the screen." I countered, "What if the person already played the game a lot and don''t want to wait for 5 seconds?". "Well... to bad for him.", he states.

True story... Morale: Don''t use sleep unless you really need it. (Your teacher says: "Use sleep.", then you do. Actually, counter your teacher with this true story.)



Visit my game programming website at www.wiseelben.com
quote:Original post by Ironica
That just compares the first letter of the char array. If you want to compare as a string:
#include <string>cin >> &buybasicsystem[0];if( strcmp(buybasicsystem, "y") == 0 )	cout <<"Test" << endl;  


Well, comparing with the first character is good too because it will also match with "y", "yes", "yeah", "yep", etc.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
quote:Original post by smart_idiot
Well, comparing with the first character is good too because it will also match with "y", "yes", "yeah", "yep", etc.




Although, it may also be a bad thing, because comparing the first byte will also match "you stupid son of a #^&*@, why the #^(& would I want to do something so abysmally moronic?" which of course does not mean "yes."

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Um... why not just do

if(buybasicsystem[0] == ''y'' || buybasicsystem[0] == ''Y'') 
instead of messing around with strcmp?
-------------"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."- Charles Babbage (1791-1871)
quote:Original post by ApochPiQ
quote:Original post by smart_idiot
Well, comparing with the first character is good too because it will also match with "y", "yes", "yeah", "yep", etc.




Although, it may also be a bad thing, because comparing the first byte will also match "you stupid son of a #^&*@, why the #^(& would I want to do something so abysmally moronic?" which of course does not mean "yes."
It''s all a matter of interpretation.


"For crying out loud, she has fishes coming out of her head on either side. How can you find this hot?!"

"If anyone sees a suspicious, camouflaged factory being carried across the desert, they should report it immediately."
quote:Original post by SoulSkorpion
Um... why not just do

if(buybasicsystem[0] == ''y'' || buybasicsystem[0] == ''Y'')  
instead of messing around with strcmp?

Ironica, was giving an example of how to compare as a string, anyway ...
if(toupper(buybasicsystem[0]) == ''Y'') would be better than that.

I dont see why buybasicsystem is an array here. (but it is early, maybe im missing something) :\
Valderman, the plural of fish is fish, not fishes, like in your sig. o.O

This topic is closed to new replies.

Advertisement