Visual C++ 6 In Record Time

Jul 14, 2012 at 6:33pm
Hey guys,
I recently got the book "Visual C++ 6 In Record Time" by Steven Holzner in hopes to learn C++
I downloaded Visual C++ 2010 for use with the book

The first thing is asked me to do is enter the following:

1
2
3
4
5
6
#include <iostream.h>

void main()
{
   cout << "Welcome to C++ \n";
}


but when I try to build "first.exe" I receive the following:

1>------ Build started: Project: first, Configuration: Debug Win32 ------
1>  first.cpp
1>c:\vcpp\first\first\first\first.cpp(4): warning C4627: '#include <iostream.h>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\vcpp\first\first\first\first.cpp(10): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Is the information in the book im reading outdated?, is it worth reading to help learn C++, because if i keep getting errors like this it will just confuse me about it more.

Thanks to anyone that can help
Jul 14, 2012 at 6:44pm
C++ header with .h extension have been deprecated for some years now.
Modern C++ also makes use of the std namespace.
void main() is not valid.

With all this in mind, you could rewrite your code as:

1
2
3
4
5
6
#include <iostream>

int main()
{
    std::cout << "Welcome to C++ 1998+ \n";
}
Jul 14, 2012 at 6:51pm
Hi Catfish2 i tried the code you gave me and received the following
1>------ Build started: Project: first, Configuration: Debug Win32 ------
1>  first.cpp
1>c:\vcpp\first\first\first\first.cpp(6): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\vcpp\first\first\first\first.cpp(17): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Jul 14, 2012 at 6:54pm
I think you should create a new project, but be sure it's an Empty Project, then add a new .cpp file to it, and paste the code.
Jul 14, 2012 at 7:09pm
I have done this and it now builds successfully!
but my problem now is it won't run.
it says it can't find the .exe

any ideas?

EDIT: i've figured this part out now i was adding a .cpp externally rather than part of my original project, but now my next problem

'hello.exe': Loaded 'C:\Users\Neil\Documents\Visual Studio 2010\Projects\hello\Debug\hello.exe', Symbols loaded.
'hello.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
'hello.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
'hello.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Cannot find or open the PDB file
'hello.exe': Loaded 'C:\Windows\System32\msvcp100d.dll', Symbols loaded.
'hello.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
The program '[3108] hello.exe: Native' has exited with code 0 (0x0).
Last edited on Jul 14, 2012 at 7:14pm
Jul 14, 2012 at 7:52pm
It looks fine to me... Have you tried starting the program "without debugging"?
I think it will also pause the console window in that case.

Otherwise, do the brave and the right thing:
go to Start->Run, type cmd.exe... then navigate to your program's location and start it.
Jul 15, 2012 at 10:22pm
Hi Catfish, apologies for the delayed reply

i've returned the book as it's clear the information is outdated (Luckily it was just from the library, so i didnt lose any money!)

i'll start C++ from scratch with more up to date information.

Thanks for your help!
Jul 16, 2012 at 6:17am
This site itself is a good start:
http://cplusplus.com/doc/tutorial/

Then simply ask for book suggestions on the forum.
Topic archived. No new replies allowed.