I am brand new... hello world

Hello everyone,
I am brand new in the world of programming and I am currently trying to do the "hello world"/ "Game Over" project.
I'm sure it is hilarious that I am having issues already I just don't know if the book I'm using is outdated or not as the code written in the book doesn't work but another code I found online does. I was just wondering what the difference (in noob terms) is between them...
1
2
3
4
5
6
7
8
9
10
11
// Game Over
// A First C++ program

#include <iostream>

int main()
{
	std::cout<<"Game Over!"<<std::endl;
	return 0;
}


That was the books code.
This is the simpler code I found...

1
2
3
4
5
6
7
8
9
10
11
12

#inc <iostream>
using namespace std;

int main()
{
      cout<<"Game Over!"<<endl;
      return 0;
}

this worked fine. Could you explain the differences please?
Last edited on
Which compiler do you use? Symbol "std::cout" not being found from standard library header "iostream" is an indication of very old version of standard library (and compiler).
I'm using microsoft visual 2012 express the second code still didn't work. there was issue's. I could show screenshots of what it says etc. Is there a way we could chat through skype or msn messenger or similar program?
Well this:
#inc <iostream>
is indeed invalid write #include
here you go the working program

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

int main()
{
      cout<<"Game Over!";               // taken out the <<endl; because it wass not needed
      system("pause")                   //keep the system open
      return 0;
}
still doesn;t work for me, I get an error saying 'program is out of date' to start off with, then when i continue it says this....

1>------ Build started: Project: Game overfirst, Configuration: Debug Win32 ------
1> Source.cpp
1>c:\users\sam's comp\documents\visual studio 2012\projects\game overfirst\game overfirst\source.cpp(8): error C2143: syntax error : missing ';' before 'return'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
ok this one worked though, what does this mean?

1
2
3
4
5
6
7
8
9
10
11

//C hello world example
#include <stdio.h>
 
int main()
{
  printf("Hello world\n");
  system("pause")
  return 0;
}
Last edited on
source.cpp(8): error C2143: syntax error : missing ';' before 'return'

Read: Line 8 has a return statement, but it looks like it is a mere suffix of the previous statement.

Indeed, line 7 does not end with ';'. system("foo") is a function call. There must be a semicolon after it.

The C-version might have some macro that does dirty things during preprocessing, like replace system("pause") with system("pause");
i think I need someone to help me via signing on to my comp to show me. Anyone willing to spend the time with me to do this?
ok this is the only one that has worked for me....

1
2
3
4
5
6
7
8
9
10

//C hello world example
#include <iostream>

int main()
{
    std::cout << "Hello, world!\n";
	system("pause");
}
Topic archived. No new replies allowed.