"Hello World" tutorials = 100% fail rates

Hey guys I'm a total beginner and I'm having a 100% fail rate no matter what I try
I have tried the "Hello World" examples from the "For Dummies" book line ("Visual Studio all in one" and "Visual C++")
I have tried the tutorial I found on this site (that goes from "Hello World" and then through heaps of other stuff)
every error message get I google (eg. Visual Studio 2010 C++ error 2106)

so:
every tutorial craps out when I go to build (Ctrl + F5) then I follow error messages in the same way as the tutoials and they are not working either
so I opened a new project (Win32 Console Application) (hoping it would be native)
I then copy and pasted:
#include <iostream>
using namespace std;

int main()
{
cout << "Hello World" << endl;
system("PAUSE");
return(0);
}

Ctrl + F5 yet again crapped out and presented error messages
any ideas?
a common resolution I came across was to re install and I've tried that to no avail
Thank you
Which errors are you getting?
i deleted
system("PAUSE");
and it worked
very beginner myself, but i think system shouldn't be there
all my tutorial tests i have been deleting them, but i am using linux and use cin.get() but i do not add it either way. But i heard i will come into problem with more complex tutorials i get into
I'm reading C++ for dummies right now and noticed he goes through things in the beginning that he just confuses people and should not even enter at that point
Last edited on
First I get a warning message come up (after I pess Ctrl + F5) = this project is out of date (project name) - Win32 debug (this one has me baffed as I installed VS 2010 last week)
code compiled:
#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])
{


#include <iostream>
using namespace std;

int main()
{
cout << "Hello World" << endl;
system("PAUSE");

return 0;
}

errors:
error C2870
error C2598
fatal error C1903: unable to recover from previous error(s); stopping compilation

second try = less this bit of code:
int _tmain(int argc, _TCHAR* argv[])
{

for some reason this time it worked (I started this thread when that didn't work)

could somebody please explain to me where I have been going wrong in this way up until now (as this is the first time this technique worked to fix this) and should I also click the solved arrow??
Thank you
Last edited on
There's a number of flaws with this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
int _tmain(int argc, _TCHAR* argv[])
 {


 #include <iostream>
 using namespace std;

 int main()
 {
 cout << "Hello World" << endl;
 system("PAUSE");

 return 0;
 }


The most serious flaw is that you define a function within a function, which is impossible. You also try to define main twice.

This code:

1
2
3
4
5
6
7
8
9
10
#include <iostream>
 using namespace std;

 int main()
 {
 cout << "Hello World" << endl;
 system("PAUSE");

 return 0;
 }


Should work on some systems, but if it doesn't, remove system("PAUSE"), like metalburr said.
1
2
3
4
5
6
7
8
#include <iostream>
using namespace std;

int main()
{
cout << "Hello World" << endl;
return 0;
}

this is exact code that ran hello world
plus for forums use, use source code , i got confused with your text and code
Last edited on
how do I put source code in to make it easier to read???
thank you guys

yeah that C++ for dummies is a total maze for us beginner types
Last edited on
under format there is a tab for <> which will put two code "things" in the text put code in between them and it will auto put it in code when you submit it
my brother lent me that book to get started with and i called him over to help me and he said just skip this, it's too advanced for a newbie , you'll learn it later
yeah page 55 through 62, when i learn that...i will go to another book to get than info later lol
C++ for dummies was written by a dummy, but i attempt to get as much out of the book as possible
C++ for dummies I'm going through slow, very slow, like i'm on page 86 in a week lol, rereading chapters over and over and doing all tests typing them in myself NOT copy and pasting so i can get familiar with typing it in
another book i like is "Programming and Principles and Practice Using C++ by Bjarne Stroustrup

I go through more cigerettes learning C++ than anything and give myself breaks lol
Last edited on
I recommend Accelerated C++: http://www.acceleratedcpp.com/
that too
thanks guys,
yup C++ for dummies could do with a re-write for sure,
it seems to me that all those examples don't want to be manipulated at all,
a decade ago I could use Qbasic to make simple ping pong games and now "Hello World" had me stumped for a week.

and yup Cigarette intake has gone through the roof for me too!!

@Metulburr I only copy and paste when the code I type craps out (as a last resort troubleshoot) to see if it is the tutorial/ example or my typing. no point spending days and days trying to perfect or learn something that was never going to work in the first place right?

closed account (zb0S216C)
You need <cstdlib> in order for system( ) to work.

Wazzak
Cheers all for your help,
problem solved ("Hello World!") now prints on screen with no error messages,
original problem still standing:
error messages appear and give a "solution" that a seasoned programmer will understand.
eg. I typed:
getline (cin mystr);
what I forgot was the comma between "cin" and "mystr"
getline (cin, mystr);
error message said I had to few arguments but no google search turns up the solution of a missing comma
could someone please point me in the direction of a dictionary type list of C++ code???
or a VS 2010 plugin that is set up to help the noob programmer spot their typos???
Cheers again guys
Last edited on
Topic archived. No new replies allowed.