Jump to content
  • Advertisement
Sign in to follow this  
Xsis

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.

If you intended to correct an error in the post then please contact us.

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 password;
  int trackparameter;
  do {
  cout<<"Please enter password: ";
  cin>> password;
  cin.ignore();
  cout<<"Please Wait.... ";
  if ( password = godnok ) {
       cout<<"Access Granted";
       }
       else {
            cout<<"Access Denied";
            }
            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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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.

Now your missing the
}while(something);
to go with your do{
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).

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

Share this post


Link to post
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!

I appreciate your help guys!

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 this post


Link to post
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 this post


Link to post
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 Xsis
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)


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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!