C++ String problems....
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….
Ive edited the program for you ;). Now it works as it should. http://rafb.net/p/nfYYLg58.html
#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…