Having trouble with visual studio 2013, code::block...

Today i started to learn C++ again, and when u installed visual studio 2010, 2013 and code::blocks (i installed all 3 because the same problem kept coming up on each install, and i was hoping for a different result). My problem is, when i open lets say visual stuidio 2013 express, and do "new project", win32 console application and start up a new program, but when i try to make "hello world" it doesnt work. I noticed that the code that shows up when u start a new program isnt what it should be :
1
2
3
4
5
6
7
#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
	return 0;
}


that is what shows up when i startup win32 console application

i tried to change it to what its supposed to be manually which would be this :
1
2
3
4
5
6
7
#include "iostream"


int main()
{
       return 0;
}


and it still dont work

I'm assuming that theres is some file somewhere in my computer that is either corrupted or just not installed right, i tried reinstalling these programs multiple times i still get the same result please help!
It's been a little while since I used VS now.

When you create a new project, make sure that you create an empty project and don't have any checkboxes for precompiled headers set.

Then, with your new, empty project, manually add a source file and use the standard C++ definition of main.

1
2
3
4
int main( int argc, char* argv[] )
{
   // Your code here
}
helps but the
#include "stdafx.h"
I'm pretty sure thats not right
Have you unchecked any options for precompiled headers? The stdafx header file is only used for precompiled headers.
yes i have, thats why im saying theres something wrong somewhere i just dont know what it is. i've used code::blocks and vs in the past and it didnt do this
Last edited on
If you create a win32 console project on VS it should compile and run without you altering any settings. But when creating a win32 console project, I do the following:

1) un-tick "precompiled header" in the new project wizard

2) change the Character Set from "Use Unicode Character Set" to "Use Multi-Byte Character Set", in Project Properties | General. Project Properties, C/C++ "Precompiled Headers"; remove "StdAfx.h" from "Precompiled header file", and remove entry for "Precompiled Header Output File"

3) change the following source-code:

1
2
3
4
5
6
7
#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
   return 0;
}


to:

1
2
3
4
int main(int argc, char* argv[])
{
   return 0;
}


4) delete the files:
stdafx.h
targetver.h
stdafx.cpp
ReadMe.txt

Then your code should still compile and run.
Last edited on
iHutch is 100% completely correct here.
i just created a blank project in vs 2010 and that's exactly what I got.
Funnily enough :)
it still dont work, but whatever i guess ill try and figure it out, c++ will just have to wait for now
it still dont work, but whatever i guess ill try and figure it out, c++ will just have to wait for now


Even after the instructions I gave you above?
it still dont work, but whatever i guess ill try and figure it out, c++ will just have to wait for now


after you have created your blank/empty C++ project in VS, you should have NO files generated for you.
Can you just confirm that?
yea its just a blank screen in VS when i open a empty C++
VS should compile and run the default program without altering any settings like disabling precompiled headers or choosing empty project.

These changes only confuses the @OP.
yea its just a blank screen in VS when i open a empty C++


Then right click on the "source files" folder, add a new .cpp file, call it "main", and copy & paste this in:
1
2
3
4
int main( int argc, char* argv[] )
{
   // Your code here
}


which is what iHutch said.
Topic archived. No new replies allowed.