Thread: net send messenger

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    7

    net send messenger

    hi im a newbie an i havent been doing c++ very long but i wanted to create a a dos based messenger program using the net send command and i managed to get a progran that can send a preprogrammed message using this command:

    /* system("net send sammain hello"); */

    but was wondering if anyone knows how to make it so i can put a new message in each time?

    cheers
    Locrieth

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Ask for user's input, Store it in a string or char array, Send it.
    I'm not sure that i understand what you mean, Because what
    you're asking seems very simple.

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    7
    ill show you what i got so far :

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <iostream.h>
    
    int main(){
    	char msg[50];
    	cout<<"Enter Message:";
    	cin>>msg;
    	
    
    	system("net send sammain");
    	system("pause");	
    	
        return 0;
    }
    i want make it so the message thats stored in the char string "msg" is sent to the computer sammain. it probably is very simple but ive not been doing this very long and i dont know how to get the msg after the compiuter name
    Locrieth

  4. #4
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Ok,

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <iostream.h>
    
    int main(){
    	char msg[50];
    	cout<<"Enter Message:";
    	cin>>msg;
    	
    
    	system("net send"+msg);
    	system("pause");	
    	
        return 0;
    }
    You could try this, Tough i have no idea what 'net send' exactly is
    so if you could please post a link so i can investigate further.

    Thank You.

  5. #5
    Registered User
    Join Date
    Jan 2003
    Posts
    7
    net send is a dos command you type net send (computer name) (message) i.e sammain is my brothers computer on our network so by putting

    net send sammain hello

    a message comes up on his screen saying hello.

  6. #6
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Wow, Never knew that, It's very handy thanks for explaining.
    Have you tried my code?

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <iostream.h>
    
    int main(){
    	char msg[50];
    	cout<<"Enter Message:";
    	cin>>msg;
    	
    
    	system("net send sammain"+msg);
    	system("pause");	
    	
        return 0;
    }

  7. #7
    Registered User
    Join Date
    Jan 2003
    Posts
    7
    yeah tried that and it didnt work now im trying to work on something where i store all the parts in char arrays so net send is stored in one then ill have one where you input the computers name then one for the message

  8. #8
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    I'm not sure what compiler you're using but how about try
    using strings?

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <iostream.h>
    #include <string.h>
    
    int main(){
    	string msg;
    	cout<<"Enter Message:";
    	cin>>msg;
    	
    
    	system("net send sammain"+msg);
    	system("pause");	
    	
        return 0;
    }

  9. #9
    Registered User
    Join Date
    Jan 2003
    Posts
    7
    im using borland c++ builder version 5.5
    i get an error message that says could not find a match for 'system(string)'

  10. #10
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    I'm not sure how strings work on your compiler, obviously
    you're using an old compiler due to the fact that you're still
    using <iostream.h >, Someone with an equal compiler
    can help?

  11. #11
    Registered User
    Join Date
    Jan 2003
    Posts
    7
    that hasnt got anything to do with the comiler i just read that on another c++ tutorial i downloaded the compiler today off the borland website i did have visual studio 6 but someone "Borrowed" it off me and that was the last i saw of it!!

  12. #12
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by Locrieth
    i did have visual studio 6 but someone "Borrowed" it off me and that was the last i saw of it!!
    Well that's a goddamn shame, VC++ 6 is an excellent compiler
    after my opinion. But as i said if you're using <iostream.h> in
    VC++ 6 you'lle recieve an error or at least a warning, telling you
    that <iostream.h> is old.

  13. #13
    Registered User
    Join Date
    Jan 2003
    Posts
    7
    WOHO sorted it

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <iostream.h>
    #include <math.h>
    
    int main(){
    	char msg[50];
    	cout<<"Enter Message:";
    	cin.getline(msg, 50, '\n'); 
    	cout<<msg;
    
    	system(+msg);
    	system("pause");	
    	
        return 0;
    }
    if i type in the whole line it works so i just gotta sort out havin the net send bit already stored ini the char msg bit at the start!

    cheers mate youve bin really helpful i wouldnt have got that +msg
    cheers
    Locrieth

  14. #14
    Registered User deltabird's Avatar
    Join Date
    Jan 2003
    Posts
    73
    I just finished a program EXACTLY like yours. The system() command cannot take a 'string' variable. This is how you do it though. Here's an example of what to do:

    Code:
    #include <iostream.h>
    #include <cstring>
    
    char first[] = "net send ";
    char msg[50];
    char final[200];
    char comp[50];
    cout<<"Enter a message: "<<flush;
    cin>>msg;
    cout<<endl<<"Enter the computer name: "<<flush;
    cin>>comp;
    strcpy(final, first);
    strcat(final, comp);
    strcat(final, " "); //puts in a space
    strcat(final, msg);
    system(final);
    Last edited by deltabird; 01-31-2003 at 02:41 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  2. changing from name in net send command
    By cfrost in forum Networking/Device Communication
    Replies: 8
    Last Post: 05-04-2004, 07:42 PM
  3. NetBIOS net send
    By -=SoKrA=- in forum Windows Programming
    Replies: 1
    Last Post: 01-22-2004, 10:21 PM
  4. Net Send
    By RoD in forum Tech Board
    Replies: 45
    Last Post: 06-08-2003, 09:49 PM
  5. Net Send Programs
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 05-15-2002, 03:48 PM