If Inside an If
Just for future references; all controll structures can be nested ( placed inside one another ).. well in C/C++ anyways
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
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.
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."
Um... why not just do
if(buybasicsystem[0] == ''y'' || buybasicsystem[0] == ''Y'')
instead of messing around with strcmp?
quote:Original post by ApochPiQIt''s all a matter of interpretation.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."
"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 doinstead of messing around with strcmp?if(buybasicsystem[0] == ''y'' || buybasicsystem[0] == ''Y'')
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) :\
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement