-
simple error...
hello,
im doing a program but ive got a problem but i cant see where the error is coming from! it seems so simple, but then the simple ones always are....
Code:
void telephone::findnme(void)
{
int i;
int result;
cout << "Finding...." << end1;
for (i=0; i,<MAX;i++) {
result = strcmp (np[i].name,name);
if result ==0)
cout <<"Book found" << end1;
else
cout << "book not found" << end1;
}
}
got a sytax error on first line and then there was an error with the << part after the "finding...."
thanks
-
Looks like end-one rather than end-ell
-
Did you declare both cout and endl? By one of the three methods:
using namespace std; (not recommended)
using std::[command]; (without []'s, not best, but better)
std::[command] (put std:: before each command, best way)
You only gave that little piece so Im not sure, it could be something else.
Note: Just a question, I do this sometimes, did you forget to include iostream?
EDIT: ooo didnt notice that was a 1, im blind :rolleyes:
-
lol - missed this as well
> if result ==0)
Missing (
-
so what would i include in std::[xyz] everything from the int part?
I have put the iostream in, admittedly i did miss it from the start!
cout is a statement in Cpp isnt it?
-
A little summon-up, to be sure:
end1 should be endl..
if result == 0) should be if (result == 0)
-
Still sadly getting them!
except now i have a "forbids i with no type" error on line 7!
but surely its been declared at the start?
-
-
Yes, the code and the errors :) Would be great..
-
Code:
for (i=0; i,<MAX;i++) {
Remove comma.
-
Sorry looked myself away and looked indepth to it!
heres the re done code
Code:
// void book::findnme(void)
// {
// int i;
// int result;
// cout<< "Finding...." <<endl;
// for (i=0; i<MAX;i++) {
// result = strcmp (np[i].name);
// if (result ==0)
// cout<<"Book found" <<endl;
// else
// cout<< ok not found" <<end1;
// }
// }
Had to hash it out to let it build!
ive got to the stage where it just says that the endl is undeclared, but i thought this was a function of Cpp or am i going mad?
also just aquick one, how do u clear an array to start? my heads going backwards!
thanks
-
p.s. just seen my mistake, but it says at this point of file on this line
Code:
result = strcmp (np[i].name);
sorry about all this guys, ive been working too long and my inteligence is sliping away..
-
What the I am sillyI am sillyI am sillyI am silly is that crap you just posted?!?
You realize that EVERY LINE IS COMMENTED OUT?
How the hell are we suppose to help you when you don't give us anything that we can use?
-
Assuming the the commenting was just a mistake you made when copying and pasting:
you still have a end1 instead of endl
strcmp takes 2 parameters
try using std::cout and std::endl instead of cout and endl
-
Yes, remove those commentes next time, and they especially wont help you, if your trying to get a product out of that code :)
The errors are as Thantos so beautifully wrote above :)