I think my logic makes sense, but the program is doing half of what I want.
the program:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string F;
string I;
string H = "inputdefault"; //a default value
string D = "outputdefault";//another default value
cout << "Enter input file: " ;
getline (cin, I);
if (I == " ") //if enter is pressed
{
I = H; //should change I to H
cout << H << endl; //should print "inputdefault" to console
}
else
cout << I << endl; //this prints any input to console, and works fine
cout << "Enter output file: " ;
getline (cin, F);
if (F == " ")
{
F = D; //should change F to D
cout << D << endl;//should print "outputdefault" to console
}
else
cout << F << endl; //this prints any input to console, and works fine
return 0;
}
My question:
why is blank returned when enter is pressed? If you don't input anything, except enter, it should output the default. Any thoughts? maybe its how the if else statements are bracketed? Let me know...