Hi

I am learning c++ at school. I am supposed to submit a project this year end. I would like to create an offline mail server using c++; something in which you can create an account and read & send messages to other existing accounts in the same computer. Once I manage to perfect this, I would like to extend it upto a LAN. I have worked out the basic logic and algorithms for the same. Please help me out!!!

You mean like this, but in c++ instead of C#?

more or less the same, it needn't have such hi-fi grapphics though

I haven't the slightest idea how to do it, but I would start with that program and see how it does the basic things.

I have come up with some ideas for signing up and logging in and sending mails. But I want something better. Here are my codes:

//registering
#include<fstream.h>
#include<conio.h>
void main()
{
  char pass[20],user[20],c=65;
  int k=0;
  cout<<"\nEnter Username: ";
  cin>>user;
  cout<<"Enter Password: ";
  while(c!=13)
  {
	c=getch();
	if(c==13)
	break;
	pass[k]=c;
	k++;
	clrscr();
	cout<<"\nEnter Username: "<<user;
	cout<<"\nEnter Password: ";
	for(int j=0; j<k; ++j)
	cout<<"*";
  }
  // creation of file
  ofstream ofile("pass.abc");
  ofile<<user<<endl;
  for(int q=0; q<k; ++q)
  ofile<<pass[q];
}

// login

// login
#include<fstream.h>
#include<conio.h>
#include<string.h>
void main()
{
  char user[20], pass[20], c=65, us[20], ps[20];
  int k=0;
  cout<<"Enter Username: ";
  cin>>user;
  cout<<"Enter Password: ";
  // for the entered charachters to appear as ****
  while(k!=20)
  {
	c=getch();
	if(c==13)
	break;
	pass[k]=c;
	clrscr();
	cout<<"Enter Username: "<<user;
	cout<<"\nEnter Password: ";
	for(int x=0; x<=k; ++x)
	cout<<"*";
	k++;
  }
  fstream ifile("pass.abc", ios::in);
  ifile.getline(us, 20);
  cout<<"\nusername: "<<us;
  ifile.getline(ps, 20);
  cout<<"\npassword: "<<ps;
  if(strcmp(user, us)==0)
  {
	 int flag=0;
	 for(int y=0; y<k; ++y)
	 {
	  if(ps[i]!=pass[i])
	  flag=1;
	 }
	 if(flag==0)
	 {
	  cout<<"\n Login Succesful";
	 }
	 else
	 cout<<"\n\t\t\t Invalid username or password!!! ";
  }
  else
	 cout<<"\n\t\t\t Invalid username or password!!! ";
}
//compose mail
#include<fstream.h>
void main()
{
 char to[20], from[20], sub[20], msg[100];
 cout<<"TO: ";
 cin.getline(to, 20);
 ofstream ofile(to);
 cout<<"FROM: ";
 cin.getline(from, 20);
 ofile<<from;
 cout<<"SUBJECT: ";
 cin.getline(sub, 20);
 ofile<<"\n"<<sub;
 cout<<"MESSAGE: ";
 cin.getline(msg, 100);
 ofile<<"\n"<<msg<<endl;
 ofile.close();
}

Can somebody help me in creating the inbox? The above codes have been written for Turbo C++ as thats what is used in our school. These codes aren't the final programs that shall make use of. I need to put these together.

Hey I wrote the following code in TURBO C++...

#include <fstream.h>
#include <conio.h>
#include <string.h>
void main()
{
  clrscr();
  int k=0;
  char p[30], u[30], c=65;
  cout<<"USERNAME: ";
  cin>>u;
  cout<<"PASSWORD: ";
  // for hiding the password entered
  while(k<30)
  {
    c=getch();
    if(c==13)
    break;
    p[k]=c;
    clrscr();
    cout<<"USERNAME: "<<u;
    cout<<"\nPASSWORD: ";
    for(int i=0; i<=k; ++i)
    cout<<"*";
    k++;
  }
  ofstream ofile("blog.abc", ios::app);
  ofile<<u<<endl;
  ofile<<p<<endl;
  cout<<"\n SUCCESS ";
  getch();
  ofile.close();
}

This program seems to work perfectly. But after executing it, i get the following warning when i come back to the editor:

WARNING
BLOG.ABC
date/ time of disk file has changed
Reload from disk?

If I select yes; then the entered username and password go into the file. Else it doesn't. But when a similar program was written at school it didn't show anything of this sort. Why am I getting this?

maybe its the compiler you are using. Try it with a good current compiler such as Code::Blocks with MinGW compiler or Microsoft VC++ 2010 Express -- both are free.

I just compiled your program with vc++ 2010 express and did not have the problem

#include <stdio.h>

#include <fstream>
#include <iostream>
#include <conio.h>
#include <string.h>
using std::ofstream;
using std::cout;
using std::cin;
using std::ios;
using std::endl;
#pragma warning(disable: 4996)

void clrscr()
{
    system("cls");
}

int main()
{
  clrscr();
  int k=0;
  char p[30], u[30], c=65;
  cout<<"USERNAME: ";
  cin>>u;
  cout<<"PASSWORD: ";
  // for hiding the password entered
  while(k<30)
  {
    c=getch();
    if(c==13)
    break;
    p[k]=c;
    clrscr();
    cout<<"USERNAME: "<<u;
    cout<<"\nPASSWORD: ";
    for(int i=0; i<=k; ++i)
    cout<<"*";
    k++;
  }
  ofstream ofile("blog.abc", ios::app);
  ofile<<u<<endl;
  ofile<<p<<endl;
  cout<<"\n SUCCESS ";
  getch();
  ofile.close();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.