Page 1 of 1

C++ makes things longer

Posted: Wed Jul 20, 2005 6:37 pm
by Red Squirrel
I never considered this, but this is kind of funny:

Code: Select all

  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);
[code]

In php:

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


:lol: 

[color=#888888][size=85]Archived topic from Iceteks,  old topic ID:3508, old post ID:28389[/size][/color]

C++ makes things longer

Posted: Wed Jul 20, 2005 6:49 pm
by Pyr-O-Rgasm
Wow. Isn't that a :censored:! Maybe not as big of one as my mom, but a :censored: none-the-less.

Archived topic from Iceteks, old topic ID:3508, old post ID:28390

C++ makes things longer

Posted: Wed Jul 20, 2005 7:11 pm
by Cold Drink
The really funny thing is your PHP code is too long :)

Code: Select all

<?php=callfunction("Listening on port $listenport");?[code]
or if short_open_tags is on
[code]<?=callfunction("Listening on port $listenport");?[code]
 

[color=#888888][size=85]Archived topic from Iceteks,  old topic ID:3508, old post ID:28391[/size][/color]

C++ makes things longer

Posted: Wed Jul 20, 2005 7:38 pm
by Red Squirrel
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. :P

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*

Archived topic from Iceteks, old topic ID:3508, old post ID:28392

C++ makes things longer

Posted: Wed Jul 20, 2005 7:39 pm
by Red Squirrel
Pyr-O-Rgasm wrote: Wow. Isn't that a :censored:! Maybe not as big of one as my mom, but a :censored: none-the-less.
LOL

I hope your mom does not happen to come and see your posts. :P Clear the history! :D

Archived topic from Iceteks, old topic ID:3508, old post ID:28393

C++ makes things longer

Posted: Wed Jul 20, 2005 8:02 pm
by Red Squirrel
Wow using strings helped...

Code: Select all

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


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;
}
[code]


Much, much easier.  But does not beat php though. :P 

[color=#888888][size=85]Archived topic from Iceteks,  old topic ID:3508, old post ID:28394[/size][/color]

C++ makes things longer

Posted: Wed Jul 20, 2005 8:09 pm
by Pyr-O-Rgasm
Red Squirrel wrote:
Pyr-O-Rgasm wrote: Wow. Isn't that a :censored:! Maybe not as big of one as my mom, but a :censored: none-the-less.
LOL

I hope your mom does not happen to come and see your posts. :P Clear the history! :D
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.

Archived topic from Iceteks, old topic ID:3508, old post ID:28395

C++ makes things longer

Posted: Wed Jul 20, 2005 8:30 pm
by Red Squirrel
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. :lol:

Archived topic from Iceteks, old topic ID:3508, old post ID:28396

C++ makes things longer

Posted: Thu Jul 21, 2005 8:07 pm
by wtd
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.

Archived topic from Iceteks, old topic ID:3508, old post ID:28451

C++ makes things longer

Posted: Thu Jul 21, 2005 9:11 pm
by Red Squirrel
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.

Archived topic from Iceteks, old topic ID:3508, old post ID:28453