Home | Forums | Articles | F@H
Help | Search | Members | Calendar | Forum Map | Cybervillage | Archive
Welcome Guest ( Log In | Register | Resend Validation Email )


>  IceTeks Forums -> Technology made cool -> Programming


  Archived - No replies allowed - start new thread insteadStart new topicStart Poll

>  C++ makes things longer
Track this topic | Email this topic | Print this topic
Red Squirrel
Posted: Jul 20 2005, 06:37 PM
Quote Post

ZOMG!

Group Icon

Group: Admins
Posts: 13 964
Member No.: 1
Joined: 18-December 02
Ice Cubes: 163183



I never considered this, but this is kind of funny:

CODE

 char listenmessage[45];
 char tmp[15];
 memset(listenmessage,0,70);
 memset(tmp,0,15);
 strcpy(listenmessage,"Listening on port ");
 sprintf(tmp,%d,listenport);
 strcat(listenmessage,tmp);
callfunction(listenmessage);


In php:

CODE

<?php callfunction("Listening on port ".$listenport);?>



laugh.gif


--------------------
user posted image
http://www.redsquirrel.me my blog
http://www.uovalor.com AoS/ML Ultima Online Shard
PMEmail PosterUsers Website Top
Pyr-O-Rgasm
Posted: Jul 20 2005, 06:49 PM
Quote Post

Liquid Nitrogen Blaster

Group Icon

Group: Moderators
Posts: 988
Member No.: 698
Joined: 17-January 05
Ice Cubes: -511



Wow. Isn't that a zzzcensored.gif! Maybe not as big of one as my mom, but a zzzcensored.gif none-the-less.
PMEmail Poster Top
Cold Drink
Posted: Jul 20 2005, 07:11 PM
Quote Post

Liquid Nitrogen Blaster

Group Icon

Group: Ice Age Members
Posts: 109
Member No.: 454
Joined: 16-July 04
Ice Cubes: 0



The really funny thing is your PHP code is too long smile.gif

CODE
<?php=callfunction("Listening on port $listenport");?

or if short_open_tags is on
CODE
<?=callfunction("Listening on port $listenport");?



--------------------
PMEmail PosterUsers WebsiteAOL Top
Red Squirrel
Posted: Jul 20 2005, 07:38 PM
Quote Post

ZOMG!

Group Icon

Group: Admins
Posts: 13 964
Member No.: 1
Joined: 18-December 02
Ice Cubes: 163183



Actually I heard that's not a good way of doing it. Not sure why though.

I just wish C++ had a nice syntax like php. tongue.gif

Strings do make things easier though, but lot of functions still use chars.

Hmm now that I think of it, I can probably use strings and dump it right in a function by going stringname.c_str(). Just thought of that now.

With strings that would cut the memset part, and make adding easier as I can just go string1 + string2.

*redesigns that part*


--------------------
user posted image
http://www.redsquirrel.me my blog
http://www.uovalor.com AoS/ML Ultima Online Shard
PMEmail PosterUsers Website Top
Red Squirrel
Posted: Jul 20 2005, 07:39 PM
Quote Post

ZOMG!

Group Icon

Group: Admins
Posts: 13 964
Member No.: 1
Joined: 18-December 02
Ice Cubes: 163183



QUOTE (Pyr-O-Rgasm @ Jul 20 2005, 07:19 PM)
Wow. Isn't that a zzzcensored.gif! Maybe not as big of one as my mom, but a zzzcensored.gif none-the-less.

LOL

I hope your mom does not happen to come and see your posts. tongue.gif Clear the history! em320.gif


--------------------
user posted image
http://www.redsquirrel.me my blog
http://www.uovalor.com AoS/ML Ultima Online Shard
PMEmail PosterUsers Website Top
Red Squirrel
Posted: Jul 20 2005, 08:02 PM
Quote Post

ZOMG!

Group Icon

Group: Admins
Posts: 13 964
Member No.: 1
Joined: 18-December 02
Ice Cubes: 163183



Wow using strings helped...


CODE

NSS_logger("Listening on port " + Int2string(listenport),0);



The int2string() function is in my custom header file and contains this:

CODE

string Int2string(int number)
{
char tmp[30];
sprintf(tmp,"%d",number);

return tmp;
}



Much, much easier. But does not beat php though. tongue.gif


--------------------
user posted image
http://www.redsquirrel.me my blog
http://www.uovalor.com AoS/ML Ultima Online Shard
PMEmail PosterUsers Website Top
Pyr-O-Rgasm
Posted: Jul 20 2005, 08:09 PM
Quote Post

Liquid Nitrogen Blaster

Group Icon

Group: Moderators
Posts: 988
Member No.: 698
Joined: 17-January 05
Ice Cubes: -511



QUOTE (Red Squirrel @ Jul 20 2005, 07:39 PM)
QUOTE (Pyr-O-Rgasm @ Jul 20 2005, 07:19 PM)
Wow. Isn't that a zzzcensored.gif! Maybe not as big of one as my mom, but a zzzcensored.gif none-the-less.

LOL

I hope your mom does not happen to come and see your posts. tongue.gif Clear the history! em320.gif

Three people living in this house, three computers. One computer per person. If she were to touch my computer I'd be pissed. Besides, I don't have AOL on my PC and she doesn't know how to work the internet without AOL.
PMEmail Poster Top
Red Squirrel
Posted: Jul 20 2005, 08:30 PM
Quote Post

ZOMG!

Group Icon

Group: Admins
Posts: 13 964
Member No.: 1
Joined: 18-December 02
Ice Cubes: 163183



LOL that's funny. Just make sure you're on a switch and not a hub... but if she can't figure out a real browser I doubt she can figure out a packet sniffer anyway. laugh.gif


--------------------
user posted image
http://www.redsquirrel.me my blog
http://www.uovalor.com AoS/ML Ultima Online Shard
PMEmail PosterUsers Website Top
wtd
Posted: Jul 21 2005, 08:07 PM
Quote Post

Liquid Nitrogen Blaster

Group Icon

Group: Ice Age Members
Posts: 157
Member No.: 532
Joined: 25-September 04
Ice Cubes: 11



Never use char arrays as strings in C++. If you really need a character array for some other function, use the c_str() member function.
PMEmail Poster Top
Red Squirrel
Posted: Jul 21 2005, 09:11 PM
Quote Post

ZOMG!

Group Icon

Group: Admins
Posts: 13 964
Member No.: 1
Joined: 18-December 02
Ice Cubes: 163183



Yeah I try to do that as much as possible. I'm glad I got to learning strings, since they make stuff a bit more like php, such as unlimited string lenghts, and no need to declare and reserve memory, etc.


--------------------
user posted image
http://www.redsquirrel.me my blog
http://www.uovalor.com AoS/ML Ultima Online Shard
PMEmail PosterUsers Website Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
« Next Oldest | Programming | Next Newest »

Topic Options Archived - No replies allowed - start new thread insteadStart new topicStart Poll

 



[ Script Execution time: 0.0353 ]   [ 13 queries used ]   [ GZIP Enabled ]

< Home | Forums | Contact >