Instant Messenger

This is a discussion on Instant Messenger within the C++ Programming forums, part of the General Programming Boards category; Hi, I am new to c++ so excuse my bad/noobish code. I have recently made an instant messenger that can ...

  1. #1
    Registered User Mahi~Mahi's Avatar
    Join Date
    May 2008
    Posts
    1

    Cool Instant Messenger

    Hi, I am new to c++ so excuse my bad/noobish code. I have recently made an instant messenger that can be used at my school (AIM is blocked ). The good thing is that it works perfectly and is actually faster than AIM, but the catch is a bad user interface. in order for me to show the text and have the user input new text, i have to use two screens. I was wondering if anyone could help me to get this thing a little bit more flashy and nice, and of course have it open with one window. If you want to test my code on two different computers than you will have to open the .exe files in a network. Thanks.

    now for the code... remember it is two different windows...

    Code:
    /********************/
    /*   LMHS IM v.2    */
    /* By: Mathew Reny  */
    /*  Date: 5/6/08    */
    /********************/
    #include <fstream>
    #include <iostream>
    #include <cstring>
    using namespace std;
    int main()
    {
      char x[200];
      char name[100];
      int loop1;
      ofstream conversationS_file ( "Conversation.txt", ios::trunc );
      conversationS_file.close();
      cout<<"LMHS IM v.2\n";
      cout<<"name: ";
      cin>>name;
      loop1 = 1; // this makes sure that the loop will not finish
    {
      do {     // start loop
      cin.getline ( x, 199 );
      //user input to friend
      ofstream conversation_file ( "Conversation.txt", ios::trunc );
      //opens conversation.txt
      conversation_file<< name <<": "<< x << endl;
      //put text into conversation.txt
      conversation_file.close();
      //closes conversation.txt 
      } while ( loop1 > 0 );
      cin.get();    // wait for a keypress
    }
    }
    and now here is the second window...

    Code:
    /********************/
    /*   LMHS IM v.2    */
    /* By: Mathew Reny  */
    /*  Date: 5/6/08    */
    /********************/
    #include <fstream>
    #include <iostream>
    #include <cstring>
    using namespace std;
    int main()
    {
      char I1[200];
      char I2[200];
      int loop1;
      cout<<"LMHS IM v.2\n";
      loop1 = 1; 
      do {     // start loop
        ifstream conversation2_file ( "Conversation.txt" );
        //open conversation.txt
        conversation2_file.getline ( I2 , 199 );
        //Reads one string from conversation.txt
        conversation2_file.close();
        //closes conversation.txt
        if ( strcmp ( I1 , I2 ) == 0 ) { }
        //if I1 = I2 then... (do nothing)
        else {
          //otherwise if I1 doensn't = I2 then...
          cout<< I2 << endl;
          //display I2 to the user
         I1[0] = '\0';      
         // strcat searches for '\0' to cat after
         strcat ( I1, I2 );     // Copy name into full name
         //i2 = i1 now
        }
      } while ( loop1 > 0 );
    cin.get();
    }
    (ps. I know you don't need the comments. Those are for me. If you could I would like comments on the new code so that i can understand it. Thanks again.)

  2. #2
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,597
    Um, I'm not sure if you did this on purpose or not, but your programs will only work if they both are exucted from the same folder on the same computer.

    But anyway, look into creating windows for your fancy ui. You should probably subclass your main single-line edit too.
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    > I have recently made an instant messenger that can be used at my school (AIM is blocked )
    Whether right or wrong, does your school have an AUP and is your fumbling around with the network to get around it a cause for concern?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    Ahem-net send-ahem.
    Wasn't mentioned in our AUP anyhow.
    Never did get around to reading it though.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need some help w/ my instant messenger
    By bikr692002 in forum Networking/Device Communication
    Replies: 2
    Last Post: 01-09-2007, 02:54 PM
  2. Instant Messenger for DOS
    By nitinol in forum C Programming
    Replies: 2
    Last Post: 12-21-2005, 09:17 PM
  3. IRC/Flood.c virus from instant messenger
    By lschmidt in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 09-27-2005, 03:41 PM
  4. Instant messenger app help
    By AusTex in forum C Programming
    Replies: 2
    Last Post: 05-01-2005, 12:41 AM
  5. Editing Instant Messenger (please help!)
    By Leeman_s in forum C++ Programming
    Replies: 6
    Last Post: 10-09-2001, 02:23 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21