ID:53777
 
[EDIT]: I lied, this is actually my second. My first was a hello world spin off that outputted "lololololol" and then 7, without a line break.

Troy[numbers]'s post recently inspired me to waste about another 30 minutes of my life trying to figure out how to use the VC++ compiler. Well, I actually figured out how to do what I wanted this time! I then read some more of the tutorial I'm learning from, and here are the fruits of my labor (not really).

#include "stdafx.h"
#include <iostream>
#include <string>


using namespace std;

int main()
{
cout << "Please tell me how many male and female pets you have that aren't neutered. First the males, then the females\n";
int malen;
int femalen;
cin >> malen >> femalen;
int kidn = (malen*femalen*6);
cout << "When all your current pets are done reproducing, you will have " << kidn << " pets\n";
cout << "When you wish to end the program, hit any key and enter. Why? 'Cause I fail at C++ right now =(";
cin >> malen;
return 0;

The above assumes that your pets are all of the same species and that incest and adultery are common occurrences


So far, I find the most difficult parts of C++ to be remembering the semicolon at the end of each line, and figuring out which data type to make your variables. By the way, anyone care to explain to me what a wide character is? All the references I found on it just said it was a wide character...
:D
o_O
Ah, it appears I discovered a bug in BYOND's HTML filter. Those end tags shouldn't appear there, I closed all my tags!
They're Unicode's retarded little brother. As I understand it, they'll allow you to use larger character sets (like Cyrillic, altered latin romance lang chars, even Korean I guess(?)).

Unfortunately, they're compiler specific and not very portable.
Jeff8500 wrote:
Ah, it appears I discovered a bug in BYOND's HTML filter. Those end tags shouldn't appear there, I closed all my tags!

O__O They shouldnt?Why not,while studying the dm guide i learned alot,I never knew the tags shouldnt appear there though.
TheMonkeyDidIt wrote:
They're Unicode's retarded little brother. As I understand it, they'll allow you to use larger character sets (like Cyrillic, altered latin romance lang chars, even Korean I guess(?)).

Unfortunately, they're compiler specific and not very portable.

Im coNfused O_________O
But I am just a Baby mudkipz
Mudkipz Liekz mudkipz.NO WAI!!!!!!
Riku 123q wrote:
Jeff8500 wrote:
Ah, it appears I discovered a bug in BYOND's HTML filter. Those end tags shouldn't appear there, I closed all my tags!

O__O They shouldnt?Why not,while studying the dm guide i learned alot,I never knew the tags shouldnt appear there though.

From the end of my post, "By the way, anyone care to explain to me what a wide character is? All the references I found on it just said it was a wide character...</<>". The </<> shouldn't be there; I closed all the HTML tags in my post.
TheMonkeyDidIt wrote:
They're Unicode's retarded little brother. As I understand it, they'll allow you to use larger character sets (like Cyrillic, altered latin romance lang chars, even Korean I guess(?)).

Unfortunately, they're compiler specific and not very portable.

Ah, thanks. Looks like I won't ever need to touch them then, which is good, since I'm probably going to have a hard time getting used to typing float, signed, etc. in front of my variable declarations, anyway!
Needs moar }
What is the point of the string lib and the stadafx.h, you're not using anything from them? o.O iostream lib is all you're using >_>
Haywire wrote:
What is the point of the string lib and the stadafx.h, you're not using anything from them? o.O iostream lib is all you're using >_>

Well, the string library was in from a prior snippet (I was playing around, should have taken it out), and the stadafx.h was in because the compiler required that I included the premade header.
Jeff8500 wrote:
Haywire wrote:
What is the point of the string lib and the stadafx.h, you're not using anything from them? o.O iostream lib is all you're using >_>

Well, the string library was in from a prior snippet (I was playing around, should have taken it out), and the stadafx.h was in because the compiler required that I included the premade header.

Make it loop and if the user enters 0 as an option the loop ends and it hits return 0 to exit the program!

Haywire wrote:
Jeff8500 wrote:
Haywire wrote:
What is the point of the string lib and the stadafx.h, you're not using anything from them? o.O iostream lib is all you're using >_>

Well, the string library was in from a prior snippet (I was playing around, should have taken it out), and the stadafx.h was in because the compiler required that I included the premade header.

Make it loop and if the user enters 0 as an option the loop ends and it hits return 0 to exit the program!

Yes ma'am. Right now I'm working on something else, though, something to test my knowledge of what I've read so far. I will include that, though, thanks!
Jeff8500 wrote:
Haywire wrote:
Jeff8500 wrote:
Haywire wrote:
What is the point of the string lib and the stadafx.h, you're not using anything from them? o.O iostream lib is all you're using >_>

Well, the string library was in from a prior snippet (I was playing around, should have taken it out), and the stadafx.h was in because the compiler required that I included the premade header.

Make it loop and if the user enters 0 as an option the loop ends and it hits return 0 to exit the program!

Yes ma'am. Right now I'm working on something else, though, something to test my knowledge of what I've read so far. I will include that, though, thanks!

I'm not a woman >_>

You should really get rid of "using namespace std;". It pollutes the global namespace. Prefix all standard library stuff with std:: and you will be good. Not to mention it will help if you ever work on a project that uses namespaces a lot. Trust me, it helps.

Also, at the end of the program you can either loop or use "std::cin.get()" to make it wait for the enter key to be pressed.

George Gough
KodeNerd wrote:
You should really get rid of "using namespace std;". It pollutes the global namespace. Prefix all standard library stuff with std:: and you will be good. Not to mention it will help if you ever work on a project that uses namespaces a lot. Trust me, it helps.

Also, at the end of the program you can either loop or use "std::cin.get()" to make it wait for the enter key to be pressed.

George Gough

Or could you not define the standard namespace just under the main so it wraps around what it's needed for?

Haywire wrote:
Or could you not define the standard namespace just under the main so it wraps around what it's needed for?


That's essentially the same effect but only restricted to the scope of main. I prefer to just type out the five extra characters but if you do something like

int main() { using namespace std; }

it would'nt be as bad as it could be.

FYI, you could also do something like this

int main() { using std::cout;using std::cin; }

That is probably the next best thing to explicitly saying std::cout when you use the object.

George Gough
KodeNerd wrote:
You should really get rid of "using namespace std;". It pollutes the global namespace. Prefix all standard library stuff with std:: and you will be good. Not to mention it will help if you ever work on a project that uses namespaces a lot. Trust me, it helps.

Also, at the end of the program you can either loop or use "std::cin.get()" to make it wait for the enter key to be pressed.

George Gough

In other words, I should put it in a header along with all my other includes, etc.?
Jeff8500 wrote:
KodeNerd wrote:
You should really get rid of "using namespace std;". It pollutes the global namespace. Prefix all standard library stuff with std:: and you will be good. Not to mention it will help if you ever work on a project that uses namespaces a lot. Trust me, it helps.

Also, at the end of the program you can either loop or use "std::cin.get()" to make it wait for the enter key to be pressed.

George Gough

In other words, I should put it in a header along with all my other includes, etc.?

He meant that instead of typing 'using namespace std;', you can do std::cout and std::cin; That's when you're working with big projects, though for this example it's not needed.
Haywire wrote:
Jeff8500 wrote:
KodeNerd wrote:
You should really get rid of "using namespace std;". It pollutes the global namespace. Prefix all standard library stuff with std:: and you will be good. Not to mention it will help if you ever work on a project that uses namespaces a lot. Trust me, it helps.

Also, at the end of the program you can either loop or use "std::cin.get()" to make it wait for the enter key to be pressed.

George Gough

In other words, I should put it in a header along with all my other includes, etc.?

He meant that instead of typing 'using namespace std;', you can do std::cout and std::cin; That's when you're working with big projects, though for this example it's not needed.

Oh, thanks.
Page: 1 2