Public Group

# Compiler Problems

This topic is 4468 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey! I've got some compiler problems, it says something with Build error.
include <iostream>

using namespace std;
trackparameter = 0
int main()
{
int trackparameter;
do {
cin.ignore();
if ( password = godnok ) {
cout<<"Access Granted";
}
else {
}
trackparameter++;
cout<<"Tracking process: "<< trackparameter <<"%";
if ( trackparameter = 8 ) {
break;
}

return 0;
cin.get();
cin.get();

}


I've been trying to create a small password thing, dosen't look to well i know :-) but still learning though! but what could be the problem? i'm using Bloodshed-dev :-) [Edited by - Xsis on July 28, 2006 3:20:40 AM]

##### Share on other sites
Your doing a "do {" without a matching "} while();"

Also:

if ( password = godnok ) {
should be

Double equal signs plus quotes surrounding text.
if ( password == "godnok") {
single equal sign means assign not equal to.

Since you have password defined as an integer I would try switching to std::string. Unless godnok is some variable you have yet to define and your password will be an integer. In which case remove the quotes around godnok.

Also, another problem:
On top you have trackparameter = 0.
This is out of scope int trackparameter; is located in the main function not ouside of it. Therefore remove trackparameter = 0. and replace int trackparameter;
with int trackparameter = 0;

##### Share on other sites
Where to begin,

First Use Source Tags it makes it easier for us to read.

Second Post the errors your compiler gies you, they typically point right at the problem.

}while(something);
as has been mentioned
you wont need to use the break if you use it right, and you'll have the same amount of {'s as }'s

trackparameter is onthere twice once with out a type or a ; (so the compiler doesn't understand it), and you don't assign it a value the second time (you don't want the first one).

Your missing another ; I'll let you figure out where.

godnok doesn't mean anything to the compiler, your using it like a varible but it hasn't been defined. I'd suggest using an integer (like a PIN code) for your password and get that working before trying to use strings. Strings are easy to add (if you use C++ strings) but considering your just starting out, I think you should get it to work with integers first..

The program ends at the return 0 the cin.get()'s are never run.

Your program while keep asking for the password even after you get it right. (And since trackparameter isn't properly initialized it can run far far more than 8 times).

DevLiquidKnight added to his post while I was writing this[/edit]

##### Share on other sites
okay! that's alot of help! thanks for the source code tags Cocalus!

C:\Dev-Cpp\Makefile.win [Build Error] No rule to make target //dkvej01fi01/DKFH0322My Documents/Hovedeforløb 2 (Forberedelse)/Programmering/Eget/password.cpp', needed by "//dkvej01fi01/DKFH0322My Documents/Hovedeforløb 2 (Forberedelse)/Programmering/Eget/password.o"'. Stop.

that's my error :-) hope this could soften it a bit!

DevLiquidKnight I don't quite understand what you mean with
Quote:
 Your doing a "do {" without a matching "} while();"

Without a matching what?

and the While(); , i've been wondering what i should put in that :-S
I can't think of it. I believe I've forgot... once again.. :-P (back to the lessons :-P)

##### Share on other sites
You are doing a do-while loop but you only have added the do { part, you need a } while( boolean expression here ); at the end of the do statement or the syntax is incorrect.

Quote:
 Original post by Xsis C:\Dev-Cpp\Makefile.win [Build Error] No rule to make target //dkvej01fi01/DKFH0322My Documents/Hovedeforløb 2 (Forberedelse)/Programmering/Eget/password.cpp', needed by "//dkvej01fi01/DKFH0322My Documents/Hovedeforløb 2 (Forberedelse)/Programmering/Eget/password.o"'. Stop. that's my error :-) hope this could soften it a bit!

This error is caused by the directory where your project file is stored contains a space in the path name. The bloodshed compiler does not like spaces in the path name. Try moving it to //dkvej01fi01/DKFH0322My_Documents/Hovedeforløb_2_(Forberedelse)/Programmering/Eget/password.cpp for instance.

##### Share on other sites
DevLiquidKnight is saying you are missing a bracket.

  do{     cout<<"Please enter password: ";     cin>> password;     cin.ignore();     cout<<"Please Wait.... ";     if ( password = godnok ) { //Here you're missing a eqaul sign. This MAKES password be eqaul                                //to a 'godnok' varaible which doesn't exist. You only want to see if password is equal to a word godnok so                                 //godnok needs to be in double quotes if its not a varaible, and you need two equals for comparison instead                                //of assignments.          cout<<"Access Granted";       }       else {            cout<<"Access Denied";       }       trackparameter++;       cout<<"Tracking process: "<< trackparameter <<"%";       if ( trackparameter = 8 ) { //Again, you need another equal sign here, for comparison. As you have                                   //it, you are making trackparameter be equal to 8       break;}  //You need another bracket '}' and you need a 'while()' after it. 'do' in itself is not a loop, and can  //only be used if you have a while() attached to the end with the value at which the loop naturally breaks at.

Quote:
 Original post by Xsisand the While(); , i've been wondering what i should put in that :-SI can't think of it. I believe I've forgot... once again.. :-P (back to the lessons :-P)

You could put:
do{//Your code}while(trackparameter != 8) //Read as 'while trackparameter does not equal 8'                           //Once it is equal to 8 it will break for you

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 13
• 64
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632967
• Total Posts
3009564
• ### Who's Online (See full list)

There are no registered users currently online

×