Hey guys I'm trying to get back in the swing of programming and I'm getting a very stupid error. It's not a syntax error so I don't know what the heck it is or means.
The answer that Bao Baboon gave probably is the most correct i think. Just because the file is open in the editor doesn't mean that its part of the program. You need to tell MSVC that it needs to be compiled as part of your program.
Press CTRL+SHIFT+A and select the file that has the main in your code. If that doesn't fix the problem, then you'll need to redefine your main to be WinMain, or set the subsystem options to console.
@pogrady
CTRL+SHIFT+A didn't do the trick and I don't know what you mean by what you mean by this
then you'll need to redefine your main to be WinMain, or set the subsystem options to console.
I use VC++ 2010 and I set the project to be Win32 Console Application (it's only type I've ever used) The code a basic program I copied from the book I was trying to see if it mattered when I altered something in the code (different from the book) but this error occurred when I was just trying to compile the way the program was written in the book. The code is as follows
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
usingnamespace std;
void changeme(int)
int main()
{
int munber = 12;
count << "the number is " << number << endl;
changeme(number);
cout << "now back in main, the value of number is " << endl;
return 0;
}
void changeme(int myvalue)
{
myvalue = 0;
cout << "now the value is " << myvalue << endl;
}
I didn't paste it before because I was embarrassed at how basic of a program it is.
@Felicia
I copied the program exactly the way it's written in the book (with the exception of capitalizing the names of the parameters)
#include <iostream>
usingnamespace std;
void changeme(int);
int main()
{
int number = 12;
cout << "the number is " << number << endl;
changeme(number);
cout << "now back in main, the value of number is " << endl;
return 0;
}
void changeme(int myvalue)
{
myvalue = 0;
cout << "now the value is " << myvalue << endl;
}
well this is weird I fixed it by recreating the project and opening the new file but I swear the only thing I did different was the way I open the .cpp file. (I right-clicked the source code folder instead of clicking the project drop down menu) must've been a fluke in the IDE.
dam I now I'm realizing I can't run the program the way I used so I don't know how to run it. I used to be able to go to debug > start without debugging but start without debugging isn't an option.