**Dev C++ HELP**

Gamingphreek

Lifer
Mar 31, 2003
11,679
0
81
Im trying to do my HW, and while I think this would work at school it is giving me non-existent syntax errors. Antiquated headers and stuff. Basically im not used to this program as at the school we use turbo C for DOS. I downloaded that and it cant find the basic <iostream.h>.

Code at the bottom. It cant find #inculude "apstrings.cpp" so i took it out (i wasn't using it). However i am using Boolean statements but when i put #include <bool.h> in it cant even find the file.

i am getting these errors:

-Wno-deprecated.

Checkbook.cpp:3:18: bool.h: No such file or directory
Checkbook.cpp: In function `int main()':
Checkbook.cpp:17: error: ISO C++ forbids comparison between pointer and integer

Checkbook.cpp:32: error: syntax error before `{' token
Checkbook.cpp: At global scope:
Checkbook.cpp:38: error: syntax error before `else'
Checkbook.cpp:41: error: syntax error before `>>' token
Checkbook.cpp:42: error: ISO C++ forbids declaration of `Balance' with no type
Checkbook.cpp:42: error: `DAmount' was not declared in this scope
Checkbook.cpp:43: error: syntax error before `<<' token

make.exe: *** [Checkbook.o] Error 1

Execution terminated


What the heck is going on here. Yes im only a Junior in high school. No im not asking for HW help but i dont know what in the world is going on with this program as im not used to using it.

*I AM NOT asking for HW help, im just unfamiliar with this program.

-Kevin
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
You shouldn't be using .h includes with new style C++, for instance just use #include <iostream>. But that may not work with your school's compiler if it's old.

However i am using Boolean statements but when i put #include <bool.h> in it cant even find the file.

I believe bool is a standard type now so you don't need that include, but again you may need it for your school's compiler if it's old.

The rest of the errors are real errors in your code.
 

aux

Senior member
Mar 16, 2002
533
0
0
Some compilers have the bool type built-in, not sure if your compiler has it. To check if it does, remove #include<bool.h> and see if the code compiles.

edit: too late, see Nothinman's post
 

Gamingphreek

Lifer
Mar 31, 2003
11,679
0
81
Oh... why do they not need .h. Is it just understood now. Also at school in order to use Apstring (Get line command) we type #include "apstrings.cpp" what would i type for that.

The rest are real errors. :-( :-(

Like syntax error before else... there isn't anything before "else" so how could there be a syntax error.

-Kevin
 

Gamingphreek

Lifer
Mar 31, 2003
11,679
0
81
It doesn't compile anyways.

Also i cant remove the h in <math.h> or i get a whole mess of errors. I cant remove math or i get a whole mess of errors.

Can someone point out one error in my code. Im not seeing anything, all cpas are where they are supposed to be, and there are no extra spaces. All lines that need it have a semi-colon at the end. All curly braces are closed properly.

I mean it is giving me these errors now:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\Makefile.win" all
g++.exe -c Checkbook.cpp -o Checkbook.o -I"C:/Dev-Cpp/include/c++/3.3.1" -I"C:/Dev-Cpp/include/c++/3.3.1/mingw32" -I"C:/Dev-Cpp/include/c++/3.3.1/backward" -I"C:/Dev-Cpp/lib/gcc-lib/mingw32/3.3.1/include" -I"C:/Dev-Cpp/include"

Checkbook.cpp: In function `int main()':
Checkbook.cpp:10: error: `cout' undeclared (first use this function)

Checkbook.cpp:10: error: (Each undeclared identifier is reported only once for
each function it appears in.)
Checkbook.cpp:11: error: `cin' undeclared (first use this function)

Checkbook.cpp:16: error: ISO C++ forbids comparison between pointer and integer
Checkbook.cpp:31: error: syntax error before `{' token
Checkbook.cpp: At global scope:
Checkbook.cpp:37: error: syntax error before `else'
Checkbook.cpp:40: error: syntax error before `>>' token
Checkbook.cpp:41: error: ISO C++ forbids declaration of `Balance' with no type
Checkbook.cpp:41: error: `DAmount' was not declared in this scope
Checkbook.cpp:42: error: syntax error before `<<' token
Checkbook.cpp:45: error: syntax error before `<<' token

make.exe: *** [Checkbook.o] Error 1

Execution terminated


Without the H's it cant even identify my output values or anything! Hell what is wrong with int main () ... how the hell could that be screwed up??

-Kevin
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Also at school in order to use Apstring (Get line command) we type #include "apstrings.cpp" what would i type for that.

And that should work fine, as long as apstrings.cpp is in the same directory as the including file.

cout and cin are part of the standard namespace, in newer C++ the compiler (atleast gcc) doesn't default to that so you either need to say 'using namespace std' at the beginning of the file or prefix all of them with std:: to specify the namespace, like std::cin.

And the else clause doesn't take an argument, it's the "if the other tests fail" branch, so you can only say else { code; }.
 

Gamingphreek

Lifer
Mar 31, 2003
11,679
0
81
I noticed the else clause like 20secs ago lol and was like "What in the hell was i thinking?" ... must have been hungry :)

As for the int main () im not sure what it is however it looks to be more of a warning than an error.

Concerning the part where i have X=="Withdraw" , does that require me to use the getline command? It says pointer to integer comparison is forbidden. I assume that means i need an APstring: getline command, or Boolean Logic doesn't like that? Is there something im missing i could have sworn i have used it smiliar to that before just not in boolean.

Thats it!

After i figure out what is wrong with my boolean statement i can get the rest of the errors.

Thanks for everything! I dont do this normally but my class is like all stupid and ive.... er jumped ahead a couple of chapters :p

-Kevin
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
After i figure out what is wrong with my boolean statement i can get the rest of the errors.

Technically it's not a boolean statement and it definately doesn't require you to include bool.h. Sure it returns a true/false for the if to evaluate, but you have to realize that you're comparing a char (i.e. a single character) to an array of characters and that's now legal. The error is a little misleading because since X is a single char it is also a single ascii integer which is what I believe g++ is doing the comparison on, and since the strings like "Withdraw" default to an array of characters you're comparing the pointer (i.e. the memory address containing the variable) to the integer value of what's in X.

Take all of that with a grain of salt, I use mostly perl these days and it handles the data conversions for me most of the time =)
 

Gamingphreek

Lifer
Mar 31, 2003
11,679
0
81
Well i remember that i have to use single quotes. Also i guess this means i need to use the getline command. SO i assume i need to instead of cin>> i need to use getline (cin::Withdraw);

I think that is right.

-Kevin