-
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.)
-
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.
-
> 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?
-
Ahem-net send-ahem.
Wasn't mentioned in our AUP anyhow.
Never did get around to reading it though.