HomeForumsWhat's newResources 
 
 
Visual C++ farking with me
Jul 17, 2002 -
   BigDAlcala Jul 17, 2002 
Ok. First I create a new text file. Then I input the following:


  Code:
Code:
  
// BranchDemo - input two numbers. Go down one path of the program if the first argument is // greater than the second or the other path if not #include <stdio.h> #include <iostream.h> int main(int nArg, char* pszArgs[]) { // input the first argument... int nArg1; cout << "Enter arg1: "; cin > nArg1; // ...and the second int nArg2; cout << "Enter arg2: "; cin > nArg2; // now decide what to do: if (nArg1 > nArg2) { cout << "argument 1 is greater than argument 2\n"; } else { cout << "argument 1 is not greater than argument 2\n"; } return 0; }


Then I hit build. It asks to start a new workspace and I click yes. Then goes to the save as txt window. I name the txt file, and then in a split second it says 0 errors and 0 warnings. When I go to execute, it says the exe file doesn't exist and asks if I want to build it. I click yes, and then it says "Cannot execute program."

What gives? Please help me! thx!

   antime Jul 17, 2002 
VC++ depends on the file extension for its default action, so save the file with the extension "cpp" and it'll work. (If you use the extension "c" it will try to compile the file as a pure C program which won't work for this program.)

You probably noticed that Ikonboard isn't the best environment for C/C++ code as it will filter out your <included files> because they look like HTML tags. To get around this, enclose your program in [CODE] tags.

   BigDAlcala Jul 17, 2002 
Cool, thx. One thing: It only lets me save as a text file. So, do I just type in filename.cpp or will it end up like filename.cpp.txt?

   antime Jul 17, 2002 
Just type in the full file name. You can also to through File/New... which will offer you a host of file types.

   BigDAlcala Jul 18, 2002 
Ok, well, I tried it again, and now I get this:


  Code:
Code:
  
--------------------Configuration: Branch Demo - Win32 Debug-------------------- Compiling... Branch Demo.cpp C:\Program Files\Microsoft Visual Studio\MyProjects\Branch Demo\Branch Demo.cpp(12) : error C2676: binary '>' : 'class istream_withassign' does not define this operator or a conversion to a type acceptable to the predefined operator C:\Program Files\Microsoft Visual Studio\MyProjects\Branch Demo\Branch Demo.cpp(17) : error C2676: binary '>' : 'class istream_withassign' does not define this operator or a conversion to a type acceptable to the predefined operator Error executing cl.exe. Branch Demo.exe - 2 error(s), 0 warning(s)



Any idea....?

   antime Jul 18, 2002 
Ah, I thought that was just Ikonboard corrupting your quote. The stream operators are << and >>, so just change your code to Code:
  
cin >> nArg1;
and it'll work just fine (I actually tested things for once).

   BigDAlcala Jul 18, 2002 
Wooohooo!! Thank you!!!! I got that code from a C++ book and the cin only had one Code:
  
<
. Wierd.