Loading
July 30, 2014, 01:01:54 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome!
 
   Forum Home   Help Search Forum Login Register  
Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: Hello, I'm brand new to C++  (Read 1576 times)
Matthew
Newbie
*
Posts: 2


« on: May 18, 2009, 12:39:08 AM »

and boy am I ever! I can't even get the first code in lesson 1 to work!

My background with C++ is in the nada to zilch range, but I want to learn because I have a goal to get into the gaming industry. I have tried a few "C++, For Beginners!" books in the past, but none have kept my attention. It's not that I get dissuaded by the daunting task of learning a new language as it is so much the minor inconveniences and technicalities of getting started. For example, the choosing of a compiler, to getting the compiler to work - it's so aggravating.

I copied the code down as it was shown in the tutorial video and I ran it. Here is what I have written down for the code:

Code:
#include <iostream>

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

That is not the problem. (or it may be, I really don't know) The problem is that when I click on "Start without Debugging" the compiler acts like it's going to do something, but then the whole console closes with no results. I reopen the console to see that everything is as it was, as if to taunt me to try it again with the hopes and dreams that what had happened before was just a fluke. I try again. It closes.

What gives?!
« Last Edit: May 18, 2009, 12:43:37 AM by Matthew » Logged
Michael Hall
Administrator
Hero Member
*****
Posts: 958



« Reply #1 on: May 18, 2009, 12:45:30 PM »

That's very unusual. I guess that you mean the IDE closed? It sounds like an installation issue. You might want to uninstall any other versions (just in case there is a conflict) and do a new install.

BTW, the project is available for download on the lesson page (zip file) if you want to try that project out.

Mike
« Last Edit: May 18, 2009, 12:47:06 PM by Michael Hall » Logged
switch3d
Newbie
*
Posts: 3


« Reply #2 on: May 18, 2009, 02:44:26 PM »

If you mean that the console itself just opened and then closed again, then you could try adding this line of code just above
Code:
return 0;
in your main function:

Code:
std::cin.get();

What this will do is run the program and then at the end wait for you to press a key before closing the console.

I hope this helps.
$witch3d
« Last Edit: May 18, 2009, 02:47:24 PM by switch3d » Logged
cantcode4nothing
Newbie
*
Posts: 1


« Reply #3 on: May 19, 2009, 10:49:45 AM »

this happened to me as i too and way new to any kind of coding whatsoever   

What happened to me is i tried to jump right into the coding part being impatient and opened the wrong type of project and down in the bottom it complained that i didnt have "#include "stdafx.h"" in the code....  but alas as i re watched the video i discovered i wasnt very good at following directions....

nothing implied, but follow the video to the t, try the pause feature <space> if he goes to fast
Logged
Matthew
Newbie
*
Posts: 2


« Reply #4 on: May 19, 2009, 03:47:56 PM »

this happened to me as i too and way new to any kind of coding whatsoever   

What happened to me is i tried to jump right into the coding part being impatient and opened the wrong type of project and down in the bottom it complained that i didnt have "#include "stdafx.h"" in the code....  but alas as i re watched the video i discovered i wasnt very good at following directions....

nothing implied, but follow the video to the t, try the pause feature <space> if he goes to fast

I put the <#include stdafx.h> in and it worked. Not sure why, but hopefully I'll understand soon enough.

I have another question, though. When I type in a different phrase instead of "Hello World!", for instance, "@#$! just got real!", it doesn't display; "Hello World!" still pops up. What is the reasoning behind this?
« Last Edit: May 19, 2009, 03:53:13 PM by Matthew » Logged
switch3d
Newbie
*
Posts: 3


« Reply #5 on: May 20, 2009, 09:42:02 AM »

Hi.

I am not sure, but this may be because you are not re-compiling the project so the "Hello World" code is still present. Just go to:

Build --> Build <PROJECT NAME>

I hope you find this useful.
$witch3d.
Logged
Rhys
Newbie
*
Posts: 10


« Reply #6 on: June 14, 2009, 12:56:51 AM »

Late reply, but if your still having trouble, add this before return 0;

Code:
system("pause");
Logged
Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!