Greetings everybody!
This is my first post, so hello to you all reading this :)
I am a new programmer, as a hobby at the moment but I am hoping I get the hang of it and get into the field I want (Learning this language is exhausting me!)
I figured the best way to put a test to my knowledge of what I have learned so far of the tuts on this websites would be to try and create a program. Maybe this isn't the best idea but who knows, I might be able to get it to work :)
The trouble I am having is the first language I designed in was when I was 12 - 14 and I was using Visual Basic, which was really easy because all you had to do was put the code into pre-defined sections (Like double click the button to edit the code that will execute if it is pressed) but recently I have noticed that, it isn't always that simple! :(
Wrapping my head around code is one thing, but then figuring out where it will all go is the next, and I am not to sure that this code is going to be efficient in what I want it to do!
My aim is to have the program search, edit, and create files (Btw I am using windows xp and don't have a compiler because I am using Linux MINT as my main OS but it just crashed on me and I lost all my code so I booted windows lol)
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? I would be very grateful! (:
Code:#include <iostream>
#include <fstream>
using namespace std;
// Function calls
int Search_for_files ( int user_input, int user_input2 );
// Function Definitions
int Search_for_files ( int user_input, int user_input2 )
{
int loop_breaker;
for ( int loop_breaker; loop_breaker = 0; ) // Calls the loop so the program will not close on an invalid input
{
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:
cout << "You have selected to go back!" << endl;
loop_breaker = 1;
break;
}
}
int main()
{
int Selection_1;
cout << "Please select an option from the list below:" << endl; // Tells the user he/she needs to make an option with the following as his/her choices
cout << " " << endl; // Put some space between the previous text :)
cout << "1. Search for files" << endl;
cout << "2. Edit a file" << endl;
cout << "3. Create a new file" << endl;
cin.ignore();
for ( int loop_breaker1; loop_breaker1 = 0;)
{
cout << "Selection: ";
cin >> Selection_1;
switch ( Selection_1 )
case 1:
cout << "Search for files selected." << endl;
loop_breaker1 = 1;
break;
case 2:
cout << "Edit a file selected." << endl;
loop_breaker1 = 1;
break;
case 3:
cout << "Create a new file selected." << endl;
loop_breaker1 = 1;
break;
default:
cout << "Invaild Selection. Please re-try, or enter 3 to close the program." << endl;
loop_breaker1 = 0;
break;
}
}