Subscribe to Journey Through Game Institute        RSS Feed
-----

Hello C++ Console apps!

Icon 2 Comments
To start, I dug up a copy of Visual C++ 2008 express edition. Visual C++ was very highly recommended, so I figured it was best to listen... they are the teachers.

Lesson 1 of C++ Module I is working with the absolute basics of C++, I/O. Admittedly, I really haven't written many C++ console apps. My job usually requires that I fix preexisting code rather than generate new code. So, this little refresher is actually kinda nice.

#include <iostream>
#include <string>

int main()
{
	std::string firstName = "";
	std::cout << "Enter your first name: ";
	std::cin >> firstName; 
	std::cout <<  "Hello " << firstName << std::endl << std::endl;

}


Woohoo.... that's some hardcore code right there lol. Oddly though, the instructions indicates that the compiling step adds the line "Press enter to continue..." at the end of the function. When I run it, that doesn't happen. Instead, I get the behavior I expected, it just prints out "Hello "+firstName.

It's really not worth dwelling on, I can just open up a terminal and run the code through it to see all the output. Doing a little googling revealed a lot of horrific ways of trying to mimic the behavior.

I've only made it 1/3 through chapter 1, but I'M SO TIRED!!! Late nights are catching up with me. That'll have to do it for today.

2 Comments On This Entry

Page 1 of 1

NickDMax Icon

29 December 2010 - 09:13 PM

Quote

It's really not worth dwelling on, I can just open up a terminal and run the code through it to see all the output.


That is the most sensible approach and one that beginners rarely seem to take. It *can* be a little irritating though to always have to run to the console. Sometimes I add some little pause code at the end of my program for expedience -- though I have added a custom "Run Program" tool that actually is just a bat file with a pause in it.
1

atraub Icon

30 December 2010 - 08:24 AM
Yeah, I can certainly understand beginners anyone wanting their programs to work EXACTLY the way they feel they should. With good ol' Python3 I can just throw in
input("Press enter to continue...")
to mimic that behavior. The way I see it, I'm re-learning C++ from the ground up for a reason... and that reason is not so that I can make the bestest console apps ever... so I don't mind it.
0
Page 1 of 1

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

November 2014

S M T W T F S
      1
2345678
9101112131415
16171819202122
2324252627 28 29
30      

Recent Entries

Recent Comments

Search My Blog

0 user(s) viewing

0 Guests
0 member(s)
0 anonymous member(s)