Originally Posted by
xScen3xHdstyl3x
I know this code is FAR from even slightly completed, but could you please tell me if I am on the right tract and what I am and what I am not doing correctly?
The most serious thing you are doing wrong is: NOT TESTING AS YOU GO!
Do not write a whole program and then try to compile it. At this point, you should try to compile your code every 5-10 lines or 15 minutes, whichever comes first. That may mean you have to add a line or two temporarily to have it make syntactical sense (eg, if you are working on a loop, you may have to use a temporary condition if the condition you are considering is not ready to evaluate. Etc.). The program does not have to do anything, but it must compile successfully. Make sure to enable your compiler warnings. Then -- if it doesn't do anything -- run the executable to make sure you don't have any unpredicted problems at runtime (such as segmentation faults).
Originally Posted by
xScen3xHdstyl3x
(Btw I am using windows xp and don't have a compiler because
This is not a good excuse. If you've used gcc on linux, you can download MinGW, a version for windows. It might take you 1/2 hour to get it working.
If you don't have access to a compiler, I strongly suggest you find something else to do in the meantime. Without being able to test, you will be prone to repeating the same error over and over again. For example:
Code:
switch ( user_input ) // Calls the switch function
case 1:
cout << "You have selected to search for files on the Hard Disk Drive." << endl; // Tells the user what he/she has selected
loop_breaker = 0; // This will break the loop, and allow the execution of other code.
break; // Breaks out of the case so the program does not fall through
case 2:
This will cause a compiler error, because the "case" statements are supposed to be inside a block:
Code:
switch (whatever) {
case 1:
case 2:
default:
}
You did that BOTH times you used a switch statement. Not such a big deal to fix, but you could just as easily have made some other syntax mistake repeatedly with something else that would require more work.
More serious potential time wasters than syntax or usage errors when you don't test your code are errors in logic which would show up if you compiled and ran:
Code:
for ( int loop_breaker1; loop_breaker1 = 0;)
{
"Loop_breaker" is uninitialized, therefore almost certainly not 0, so presuming you meant "==" there, your loop will break before it runs even once. And if you meant "=", it will never not break. Two cascading errors in one line!
Again, not so serious, but it could just as easily have been something that would require you to rewrite a bunch of code -- because you thought about one thing the wrong way. The process of compiling, testing, and correcting also forces you to focus more on your code. Eg, the use of the "loop_breaker" variable is superfluous to the use of the "Selection_1" variable. You'll be able to simplify the code if you remove one or the other.