Could someone give me an example of one or a link to one.
I'm supposed to write one for class and can't find an example in the book.
Thanks much-
Could someone give me an example of one or a link to one.
I'm supposed to write one for class and can't find an example in the book.
Thanks much-
Code:bool test(int x) { if(x) return true; return false; }
i seem to have GCC 3.3.4
But how do i start it?
I dont have a menu for it or anything.
Here's another one:
Code:#include <iostream> using namespace std; bool canRide(int num) { if(num < 48) return false; else return true; } int main() { int input = 0; cout<<"Enter your height in inches: "; cin>>input; if(canRide(input)) cout<<"Please proceed through the gates\n" <<"and enjoy the roller coaster."<<endl; else cout<<"For safety reasons, you are not allowed\n" <<"on this roller coaster. Sorry."<<endl; return 0; }
A true bool function:
Code:bool Bool(bool Bool) { return Bool; }
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
Last edited by The Brain; 04-22-2005 at 09:14 AM.
- "Problem Solving C++, The Object of Programming" -Walter Savitch
- "Data Structures and Other Objects using C++" -Walter Savitch
- "Assembly Language for Intel-Based Computers" -Kip Irvine
- "Programming Windows, 5th edition" -Charles Petzold
- "Visual C++ MFC Programming by Example" -John E. Swanke
- "Network Programming Windows" -Jones/Ohlund
- "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
- "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel
Thanks for the input.
How's this? I'm supposed to determine if I am at the end of a sentence. If '.' or '?' or '!', return true, else return false.
Code:bool IsEndOfSentence(char MyChar){ while(MyChar >> MyFile){ switch(MyChar){ case '.': return true; break; case '?': return true; break; case '!': return true; break; default: return false; } } }
You should tell your instructor that you have no idea how to write a "bool" function, so you wrote a "predicate" instead.
The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.
I don't know how the rest of your program works, but I find that while loop to be suspect.
FAQ
"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.
"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.
> while(MyChar >> MyFile){
This part should be outside the function. This should be in main(), or whatever function calls this function.
yes, IsEndOfSentence accepts a single char and should check if that chars is '.', '!' or '?' . The Brain's example above should give you a good idea.
To sum it all up, get rid of the while loop and it should work.
Also, you don't need the breaks in that example, because before it can reach any of the breaks it is returning from the function.
nerds unite!
I'm using windows XP.
I'm using dev-C++ by bloodshed.