en972![]() Member Posts: 562 From: NOT TELLING! Registered: 08-27-2004 |
Ok, I'm writing this code (some of you have seen it and helped me). All that you guys have told me works great so far, and because it, I have added more stuff. But now comes the time where I need help again *sigh* Below I'll post the errors than the code (note, not all of the code is finished, so if you see some weird variables, like, "politician" don't freak out. Oh, and i'm using Dev-Cpp power by wx widgets. Compiler: Default compiler C:/Dev-Cpp/C++ Lists/kerry cons.cpp:27: error: syntax error before numeric C:/Dev-Cpp/C++ Lists/kerry cons.cpp:29: error: cannot declare static function inside another function C:/Dev-Cpp/C++ Lists/kerry cons.cpp:81: error: syntax error at end of input Execution terminated
cout<< "Type the name of a folder below to access it." <<endl;
------------------ |
||
CobraA1![]() Member Posts: 926 From: MN Registered: 02-19-2001 |
quote: Should be: Or at least: "static void" is for declaring a function, not using it. "unsigned long" is just the type, and probably isn't needed. The computer doesn't know what the word "milliseconds" means You can make your code more efficient, BTW, but I'll tell you how after we've fixed the errors. ------------------ Switch Mayhem now available! Get it here |
||
CPUFreak91![]() Member Posts: 2337 From: Registered: 02-01-2005 |
HOLY MACK TRUCK! I CAN READ THAT! And it makes sense! C/C++ to boot! I might have a chance at C/C++ still! ------------------ |
||
en972![]() Member Posts: 562 From: NOT TELLING! Registered: 08-27-2004 |
Thanks CPU freak. I just got home from church, so after I eat I'll check it out ------------------ |
||
en972![]() Member Posts: 562 From: NOT TELLING! Registered: 08-27-2004 |
The Sleep(3); works. though I got an error that says sleep has not been declared. Also it still says syntax error. A little help? ------------------ |
||
CobraA1![]() Member Posts: 926 From: MN Registered: 02-19-2001 |
quote: Apparently it's a function from the windows library. Add to the top of your program: If you still get errors, list them here so we can see them. ------------------ Switch Mayhem now available! Get it here |
||
Seven7 Member Posts: 50 From: USA Registered: 03-16-2005 |
Why are you writting your own "Sleep" function?! Just use the function that is provided to you. Why reinvent the wheel? However, IF you feel that you need to write your own: "static void Sleep(unsigned long 3 milliseconds);" "static void Sleep(unsigned long milliseconds = 3);" Also, you dont need to have static functions j. |
||
en972![]() Member Posts: 562 From: NOT TELLING! Registered: 08-27-2004 |
Wow, thanks man. I have 2 questions. 1. Why cant I use using namespace std; everyone says that is not good 2. How can I make my code easier to read and more efficiant
------------------ |
||
CobraA1![]() Member Posts: 926 From: MN Registered: 02-19-2001 |
quote: Dunno. I use it.
quote: Declaring all your strings seems kinda redundant.
can be replaced with:
But that may actually be bad advice if you want to change your strings later. Or better yet, store your password as an MD5 hash in a database. But that may be a bit out of your abilities right now So far, so good Edit: 800th post! Woohoo! ------------------ Switch Mayhem now available! Get it here [This message has been edited by CobraA1 (edited April 18, 2005).] |
||
CoolJ![]() Member Posts: 354 From: ny Registered: 07-11-2004 |
I agree, I don't see anything wrong with: using namespace std; One suggestion might be to start thinking about what could be classes/objects. I see two classes that are begging to be made from your code... class System - the system that is being accessed this class could have methods such as Boot(), Logon(), Logoff() class User - the user logged into the system |
||
CoolJ![]() Member Posts: 354 From: ny Registered: 07-11-2004 |
Please ignore this post if your not interested in an example of making a System class and User class. I just wanted to show how you might do this. Here's the following list of users/passwords for the system logon: jkerry wannabeprez1
#include <time.h> // i had to create this sleep function, you might have to just use yours
string name; // methods };
// methods
// load valid users list. could be kept in file. // system boot prompts..
// prompt for user name // prompt for password cout<< endl; //space things out // return user if successful
// if found username is a valid system user // returns pointer to user object if successful, // method: System::Logoff sleep(3); return;
// system boot if (curUser == NULL) sleep(3); // logon successful sleep(3); // logoff user
**COPY & PASTE ENDING HERE **** [This message has been edited by coolj (edited April 18, 2005).] |
||
Seven7 Member Posts: 50 From: USA Registered: 03-16-2005 |
Hi,
quote:
FYI: The code above is equivalent to: std::cout << "Hello World" << std::endl; or The code above is equivalent to: These two examples apply to header files only. You can have name spaces
j. |
||
CobraA1![]() Member Posts: 926 From: MN Registered: 02-19-2001 |
Correct me if I'm wrong, but it's inadviseable to create an infinite loop as a sleep function anymore. It'll throw your CPU into 100%, and isn't very thread aware. A proper sleep function should tell the OS to sleep the thread, so the OS can give resources to other threads. So I advise using the built-in sleep functions. ------------------ Switch Mayhem now available! Get it here |
||
Seven7 Member Posts: 50 From: USA Registered: 03-16-2005 |
CobraA1, The "Sleep(...)" function does not put a thread into an infinite loop, "Sleep(90000000000000000000000000000000000000000000000000000)" In theory My point to the "FYI" is an example of the good usage of the "Sleep(..)" j. [This message has been edited by Seven7 (edited April 19, 2005).] |
||
CobraA1![]() Member Posts: 926 From: MN Registered: 02-19-2001 |
I was talking about coolj's code . . . ------------------ Switch Mayhem now available! Get it here |
||
en972![]() Member Posts: 562 From: NOT TELLING! Registered: 08-27-2004 |
K, thanks guys. I have my new code. Will post soon. theres some stuff to do... ------------------ |
||
CoolJ![]() Member Posts: 354 From: ny Registered: 07-11-2004 |
quote: Yeah..ignore my sleep function..thanks for pointing that out! |