Page 1 of 1 [ 9 posts ] 

Arsenic
Hummingbird
Hummingbird

User avatar

Joined: 21 Jan 2006
Gender: Male
Posts: 20

31 Mar 2006, 12:20 pm

I'm learning c++ yay!, my first program:


#include <iostream>
#include <stdlib.h>

{

//a simple program


int age;
char name[24];
char color[24];

cout << "hello, what is your name?\n";
cin >> name;
cout << "and your age?\n";
cin >> age;
cout << "and lastly whats your favorite color?\n";
cin >> color;
cout << "ok, your name is " << name;
cout << ", you are " << age << " years old, ";
cout << " and you favorite is\n" << color << endl;
cout << endl;
cout << endl;
if (age > 50) cout << "your getting on in life";
if (age < 50) cout << "your doing ok age wise" << endl;

system("PAUSE");
return 0;
}



Silver_Shadow
Blue Jay
Blue Jay

User avatar

Joined: 5 Feb 2006
Gender: Male
Posts: 78
Location: United Kingdom

31 Mar 2006, 12:23 pm

Thats really good. Are you teaching yourself or going to lessons?



kolrabi
Snowy Owl
Snowy Owl

User avatar

Joined: 19 Sep 2005
Gender: Male
Posts: 149

31 Mar 2006, 12:50 pm

What if the name is longer than 23 characters? :)


_________________
"begin da meltdown - bad enough and justified"


larsenjw92286
Veteran
Veteran

User avatar

Joined: 30 Aug 2004
Age: 37
Gender: Male
Posts: 8,062
Location: Seattle, Washington

31 Mar 2006, 3:29 pm

Wonderful!


_________________
Jason Larsen
[email protected]


ljbouchard
Veteran
Veteran

User avatar

Joined: 4 Mar 2005
Gender: Male
Posts: 1,278
Location: Rochester Minnesota

31 Mar 2006, 3:59 pm

kolrabi,

Give him a break. He has not gotten to the chapter on pointers and strings yet.


_________________
Louis J Bouchard
Rochester Minnesota

"Only when all those who surround you are different, do you truly belong."
---------------------------------------------------
Fred Tate Little Man Tate


Awesomelyglorious
Veteran
Veteran

User avatar

Joined: 17 Dec 2005
Gender: Male
Posts: 13,157
Location: Omnipresent

31 Mar 2006, 5:42 pm

That is sort of cool. I have never learned C++ but I think it would be cool if I did and it is possible that I will someday. I hope you keep up the good work, Arsenic! Programming is rewarding to many people in many different ways.



pernicious_penguin
Pileated woodpecker
Pileated woodpecker

User avatar

Joined: 1 Sep 2005
Age: 53
Gender: Male
Posts: 183

01 Apr 2006, 8:56 am

kolrabi wrote:
What if the name is longer than 23 characters? :)


buffer overflow, if you are clever you can exploit this further



NeantHumain
Veteran
Veteran

User avatar

Joined: 24 Jun 2004
Age: 44
Gender: Male
Posts: 4,837
Location: St. Louis, Missouri

01 Apr 2006, 2:04 pm

pernicious_penguin wrote:
kolrabi wrote:
What if the name is longer than 23 characters? :)


buffer overflow, if you are clever you can exploit this further

Code:
std::string part1 = "then j00 pr0ggy just g0t ";
std::cout << part1 << "OMG pwnd!! !!" << std::endl;



BlackLiger
Veteran
Veteran

User avatar

Joined: 21 Apr 2005
Gender: Male
Posts: 1,525
Location: My Posh Leather Chair. England.

01 Apr 2006, 6:21 pm

NeantHumain wrote:
pernicious_penguin wrote:
kolrabi wrote:
What if the name is longer than 23 characters? :)


buffer overflow, if you are clever you can exploit this further

Code:
std::string part1 = "then j00 pr0ggy just g0t ";
std::cout << part1 << "OMG pwnd!! !!" << std::endl;


Don't mix l33t and coding, it causes ALL sorts of messups in windows... not sure how Linux handles it...

I comment my code in l33t, however.


_________________
"Where are we going and why are we in this handbasket?"