Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

C++ String problems....


ghost's Avatar
0 0

I submitted this bit of code to the code bank: http://www.hellboundhackers.org/code/readcode.php?id=318

Now im trying to improve upon it. For example, at the moment the message string being sent for some strange reason cannot contain spaces (the moment you hit space the program stops taking input and sends the net send) - it's gotta have dashes in it. I did a bit of googling and found::

getline(cin, blablabla);

I made a simple program with it and was able to input strings with spaces in it. Now heres my problem: When i replaced my cin >>'s with the getline's and compiled everything was hunky-dorey(ok) BUT when i run the exe and get to the stage where i can input my message it just skips the whole input stage and tries to send the net send. Can someone please explain to me: a.) what the hell is going on (I really have no clue) b.) and how can I fix it….


ghost's Avatar
0 0

Try sticking this before you accept input from the user.

std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

~T:ninja:


ghost's Avatar
0 0

I heard your better a sticking it up your ass , LOL


ghost's Avatar
0 0

sirus why do you pick fights:angry:


ghost's Avatar
0 0

Ya that is very uncalled for….

about the snippet of code you gave me, Im getting a small error:

macro 'max' used without args

What do I need to do to get rid of this, google isnt doin much for me atm…

thanks.


ghost's Avatar
0 0

Get on HBH IRC channel, ill explain it to ya. Or if you have some instant messenger PM me with your screenname.


ghost's Avatar
0 0

Awesome! Thanks John!

Neat workaround you made there! You are a god, thanks again!


ghost's Avatar
0 0
#include <stdio.h>

int main(int argc, char **argv)
{
    int n;
    char cmd[256];
    if (argc != 4) {
        printf("Usage:\n%s [pcname] [message] [count]", argv[0]);
        exit(0);
    }
    sscanf(argv[3], "%d", &n);
    sprintf(cmd, "net send %s %s", argv[1], argv[2]);
    while (n--)
        system(cmd);
    return 0;
}

why are you always complicating things…


ghost's Avatar
0 0

it isn't complicated..


ghost's Avatar
0 0

0X702CH wrote: why are you always complicating things…

Perhaps you should stop writing code vulnerable to buffer overflows?

Cheers, ~T


ghost's Avatar
0 0

vvvvv[img]http://www.planetclimax.com/pics/f


ghost's Avatar
0 0

vvvvv[img]http://www.planetclimax.com/pics/f