Jump to content

Starting with C++


Miek

Recommended Posts

I am taking Computer Science at University and part of it is learning C++. However, I'm having some serious problems with... everything...

 

I'm trying to do the usual first "Hello World!" program. I am pretty sure I have the code right, but I just can't seem to find how to make some kind of viewable result.

 

// This will print Hello World!

#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}

 

I'm using Microsoft Visual Studio 2010 Express. How can I produce some kind of launchable, viewable result? My textbook (that cost over $150 >.>) isn't much help, outdated, and is showing that a window with "Hello World!" is somehow magically appearing after doing nothing more than entering the code in a C++ compiler. I think they skipped a few steps.

 

Help?

Share this post


Link to post
Share on other sites

  • Replies 41
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

I am taking Computer Science at University and part of it is learning C++. However, I'm having some serious problems with... everything...

 

I'm trying to do the usual first "Hello World!" program. I am pretty sure I have the code right, but I just can't seem to find how to make some kind of viewable result.

 

// This will print Hello World!

#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}

 

I'm using Microsoft Visual Studio 2010 Express. How can I produce some kind of launchable, viewable result? My textbook (that cost over $150 >.>) isn't much help, outdated, and is showing that a window with "Hello World!" is somehow magically appearing after doing nothing more than entering the code in a C++ compiler. I think they skipped a few steps.

 

Help?

 

Hi Meik, Welcome to C / C++ programming. You have missing the .h on your library declaration. This should have given you a compiler error to warn you of that.

Edited by dihartnell

Share this post


Link to post
Share on other sites

It still doesn't seem to be working. The code I used is straight from the textbook, so I would think that it's right. I'm not saying yours is wrong... It's probably accomplishing the same task with a different method, correct?

 

I'm also trying to figure out how in Visual Studio 2010 Express I actually compile source code into some kind of executable that I can launch and make the window with "Hello World" appear.

 

 

I think I'm going to have to check back here tomorrow... I have Statistics class tomorrow and I should probably get some sleep before then.

 

I appreciate the help a lot.

Edited by Miek

Share this post


Link to post
Share on other sites

I have this feeling you didn't actually create the project the right way, as a console application. See this for an example, replace code with your own.

This.

 

Once you have the correct project created and add your cpp file under source files, I believe the menu you need to go into is Debug -> Start without debugging. This should compile and run the program.

Share this post


Link to post
Share on other sites

Your program will run and complete without you seeing anything because it just pops up and goes away faster than you can see it. Adding in a system("pause"); will put a pause in the program before it ends so you can actually see the output to the console window.

 

#include <iostream>

 

using namespace std;

 

int main()

{

cout << "Hello world";

system("pause");

}

Edited by Gr4vitas

Share this post


Link to post
Share on other sites

Support for 64bit (integer) types, larger and increased number of registers, larger virtual and physical address space. Also the CPU instruction set is extended in order to take advantage of these modifications. Regarding address space, there are some hardware limitations that might limit the expected "64bit". For example AMD64 is limited to 40bit (extended to 48bit by a few tricks) virtual address space and a 36bit (extended to 52bit by a few tricks) physical address space, somewhat limited compared to the full blown 64bit address space, but in reality, other physical limitations will be reached before the actual capabilities of the architecture are.

Share this post


Link to post
Share on other sites

I am taking Computer Science at University and part of it is learning C++. However, I'm having some serious problems with... everything...

 

I'm trying to do the usual first "Hello World!" program. I am pretty sure I have the code right, but I just can't seem to find how to make some kind of viewable result.

 

// This will print Hello World!

#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}

 

I'm using Microsoft Visual Studio 2010 Express. How can I produce some kind of launchable, viewable result? My textbook (that cost over $150 >.>) isn't much help, outdated, and is showing that a window with "Hello World!" is somehow magically appearing after doing nothing more than entering the code in a C++ compiler. I think they skipped a few steps.

 

Help?

 

So, If you'd like, I can get in touch with you, and help you through this, just PM and I will contact you

 

Like has been said by others in the post

add a cin.get();

right after your cout

 

If you use system("pause");

you'll have to #include in your preprocessor section (which is currently #include

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×
×
  • Create New...