While learning the basics of C++, I wrote the code below and when I used the command in "Visual Studio 2008 Command Prompt" like so ---
C:\.......>cl -EHsc If.cpp (The code file is named "If")
Then it gave me the new If.exe and If.obj. OK fine there right?
Then when I run the If.exe it says "The syntax of the command is incorrect".
So, just to double check I copy and paste the code from the if.cpp into Microsoft Visual C++ 2008 express edition under a new project and a new item in the resource files and compile it. OK again...
Then I go find this new .exe and run it and it works...
#include <iostream>
usingnamespace std;
int main()
{
int a, b, c;
a = 2;
b = 3;
if(a < b) cout << "a is less than b\n";
if(a == b) cout << "you won't see this\n";
cout << "\n";
c = a - b;
cout << "c contains -1\n";
if(c >= 0) cout << "c is non-negative\n";
if(c < 0) cout << "c is negative\n";
cout << "\n";
c = b - a;
cout << "c contains 1\n";
if(c >= 0) cout << "c is non-negative\n";
if(c < 0) cout << "c is negative\n";
system ("pause");
return 0;
}
*note the system ("pause") is just there to stop the prompt from closing ...I know there are other codes to do this but was just testing.