I'm getting an error X#=0D,CS=0A97 IP=000001D1.The NTVDM CPU has encountered an unhandled exception . I wrote exactly the same program, but still i'm getting an error! Can you please tell me where the error has occured? Because i'm not able to find out! I'm Using Windows 7.

http://www.4shared.com/file/xvAIAHNz/TELEPHON.html

http://www.4shared.com/file/2SOg9Kqs/TELEPHON.html

This Is my project! Please help me out as sson as possible!

Recommended Answers

All 6 Replies

Could you post a small but complete program that exhibits the problem here? We're not generally keen on downloading things, and it makes it harder to eyeball the code quickly.

This sort of low-level exception is frequently caused by unaligned variables in your structures. As decepticon notes, you need to provide some of your source, including structures and where they are used.

Can you just explain me a little more?
When i'm compiling, it is compiling like 1000 or so lines but then it is giving the error. What to do?

What to do is to post the code here so people can view it instead of linking to external resources.

It's like 3000 lines of code!

TELEPHONE DIRECTORY Program :

#include<iostream.h>
#include<fstream.h>
#include<iomanip.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#include<graphics.h>
#include<dos.h>


class tele
{
    public :
    char name[20];
    char address[20];
    unsigned int phone_no;
    void get(void);
    void show(void);
    void modify(void);
};

void tele::get(void)
{
    int i = 0 ;
    cout<<" \n Enter Name : ";
    cin.get(name[i]);
    while(name[i] != '\n')
    {
      i=i+1;
      cin.get(name[i]);
    }
    cin.getline(name,20,'\n');
    cout<<" \n Enter Address : ";
    cin.getline(address,20,'\n');
    fflush(stdin);
    cout<<" \n Enter Phone No. : ";
    cin>>phone_no;
    fflush(stdin);
}

void tele::show(void)
{

    cout<<" \n ";
    cout<<" Name : " <<name<<" \n ";
    cout<<" Address : "<<address<<" \n ";
    cout<<" Phone Number : "<<phone_no<<" \n ";

}

int main()
{
    int gdriver = DETECT, gmode, errorcode;
    int x,y;
    int midx, midy;

    initgraph(&gdriver, &gmode, "");
    errorcode=graphresult();
    if(errorcode != NULL)
    {
      printf(" Graphics Error : %s \n ", grapherrormsg(errorcode));
      printf(" Press Any Key To Halt!!! ");
      getch();
      exit(1);
      closegraph();
    }
    y :
    char*pass=" RPV";
    char*ppass;
    gotoxy(25,8);
    int size=7;
    settextstyle(7,0,size);
    setbkcolor(BLUE);
    setcolor(WHITE);
    outtextxy(180,50,"WELCOME");
    setcolor(WHITE);
    outtextxy(250,200, "TO");
    settextstyle(8,0,5);
    setfillstyle(1, DARKGRAY);
    setcolor(WHITE);
    outtextxy(60,350, " \n \n TELEPHONE DIRECTORY ");
    getch();
    clearviewport();
    settextstyle(3,0,4);
    settextstyle(7,0,4);
    getch();
    clearviewport();

    g:
    ppass=getpass(" ENTER THE PASSWORD : ");
    if(strcmpi(pass,ppass) != 0)
    {
      cout<<" \n \t \t \t Incorrect Password ";
      cout<<" \n \n \t \t \t Try Again ";
      getchar();
      goto g;
    }
    else                   //else is not closed
    {
      tele s;
      char name[20];
      char namel[20];
      int ch;
      clrscr();
      setbkcolor(BLUE);
      setcolor(YELLOW);
      closegraph();
    z:
    cout<<" \n \n \n \n \n \n \n ";
    initgraph(&gdriver,&gmode,"c:\\tc\\bgi");
    setcolor(BLUE);
    rectangle(60,10,600,400);
    setfillstyle(1,YELLOW);
    bar(61,11,599,399);
    outtextxy(220,30," HELP -> PRESS ANY KEY 1 TO 6 ");
    settextstyle(TRIPLEX_FONT , HORIZ_DIR,4);
    outtextxy(220,50," \n \n 1. TO ADD " );
    setcolor(BLUE);
    settextstyle(TRIPLEX_FONT, HORIZ_DIR, 4);
    outtextxy(220,100," \n \n 2. TO SHOW " );
    setcolor(BLUE);
    settextstyle(TRIPLEX_FONT , HORIZ_DIR,4);
    outtextxy(220,150," \n \n 3. TO SEARCH " );
    setcolor(BLUE);
    settextstyle(TRIPLEX_FONT, HORIZ_DIR, 4);
    outtextxy(220,200," \n \n 4. TO MODIFY " );
    setcolor(BLUE);
    settextstyle(TRIPLEX_FONT, HORIZ_DIR, 4);
    outtextxy(220,250," \n \n 5. TO DELETE " );
    setcolor(BLUE);
    settextstyle(TRIPLEX_FONT, HORIZ_DIR, 4);
    outtextxy(220,300," \n \n 6. TO EXIT " );
    setcolor(BLUE);
    settextstyle(TRIPLEX_FONT, HORIZ_DIR, 3);
    outtextxy(220,350," Enter The Choice -> " );

    gotoxy(62,23);
    cin>>ch;


switch(ch)
{
  case 1 :
  {
    clrscr();
    fstream f;
    f.open("rec",ios::in|ios::out|ios::ate|ios::app|ios::binary);
    char ans;
    s.get();
    f.write((char*)&s,sizeof(s));
    clrscr();
    outtextxy(250,360," Do You Want To continue? ");
    ans=getche();
    if(ans=='Y' || ans=='y')
    {
      goto z;
    }
    f.close();
    break;
  }

  case 2 :
  {
    clrscr();
    cout<<" \n \n ";
    fstream f;
    f.open("rec", ios::in|ios::out|ios::ate|ios::app|ios::binary);
    f.seekg(0);
    int ctr=0;
    while(f.read((char*)&s,sizeof(s))
    {
      ctr=ctr+1;
      if(ctr==8)
      {
        getchar();
        clrscr();
        ctr=0;
      }
      s.show();
      if(f.eof()==1)
      {
        break();
      }
    }

    f.close();
    outtextxy(240,350, " Do You Want To Continue? ");

    char ans;
    ans=getche();
    if(ans=='y' || ans=='Y')
    {
      closegraph();
      goto z;
    }
    else
    {
      exit(1);
    }

  }


  case 3 :
  {
    gotoxy(60,25);
    clearviewreport();
    rectangle(10,10,630,470);
    setbkcolor(DARKGRAY);
    textbackground(3);
    textcolor(5);
    clrscr();
    char ans;
    ifstream f;
    tele s;
    char name[20];
    char address[20];
    unsigned int ph_no;
    f.open("rec",ios::in|ios::binary);
    cout<<" \n \n \n Enter Name Whose record to be search : ";
    cin>>name;
    do
    {
      f.read((char*)&s,sizeof(s));
      if(f.eof()==1)
      {
        break;
      }
      if(strcmpi(s.name,name)==0)
      {
        cout<<" \n Name : "<<s.name;
        cout<<" \n  Address : "<<s.address;
        cout<<" \n Phone Number : "<<s.ph_no;
        getchar();
      }
    }
    while(f);
    f.close();
    settextstyle(7,0,1);
    outtextxy(250,410, " Do You Want To Continue? ");
    ans=getchar();
    if(ans=='y'||ans=='Y')
    {
      goto z;
    }
    else
    {
      closegraph();
    }
    break;
  }

  case 4 :
  {
    clrscr();
    char ans;
    fstream f;
    tele s;
    char name[20];
    char address[20];
    unsigned int ph_no;
    f.open("rec", ios::in|ios::binary);
    cout<<" \n \n Enter The person's phone number whose record is to be changed : ";
    cin>>ph_no;
    do
    {
      f.read((char*)&s,sizeof(s));
      if(f.eof()===1)
      {
        break;
      }
      if(s.ph_no===ph_no)
      {
        cout<<" \n Current Name : "<<s.name;
        cout<<" \n Current Address : "<<s.address;
        cout<<" \n Current Phone Number : "<<s.pj_no;
        cout<<" \n Enter the new name : ";
        cin>>name;
        cout<<" \n Enter the city : ";
        cin>>address;
        cout<<" \n Enter the new phone number : ";
        cin>>ph_no;
        strcopy(s.name,name);
        strcopy(s.address,address);
        s.ph_no=ph_no;
        int l=f.tellg();
        f.close();
        f.open("rec", ios::out|ios::binary|ios::ate);
        f.seekg(1-sizeof(s));
        f.write((char*)&s,sizeof(s));
      }
    }
    while (f);
    f.close();
    outtextxy(290,360, " Do you want to continue? ");
    ans=getche();
    if(ans=='Y'||ans=='y')
    {
      goto z;
    }

    break;
  }


  case 5:
  {
    clrscr();
    char name[20];
    tele s;
    ifstream fin;
    fstream fout;
    fin.open("rec", ios::in|ios::binary);
    fout.open("va",ios::app|ios::binary);
    cout<<"\n \t \t \t DELETING :  ";
    int i;
    fflush(stdin);
    cout<<" \n \n Enter the name : ";
    cin.get(name[i]);
    while(name[i]!='\n')
    {
      i=i+1;
      cin.get(name[i]);
    }
    fflush(stdin);
    fflush(stdout);
    cin.getline(name,20,'\n');
    while(fin)
    {
      fin.read((char*)&s,sizeof(s));
      if(strcmp(s.name,name)==0)
      {
        fout.read((char*)&s,sizeof(s));
      }
      else
      {
        if(fin.eof()==1)
        {
          break;
        }
        fout.write((char*)&s,sizeof(s));
      }
    }
    fin.close();
    fout.close();
    system(" del rec");
    cout<<" \n Enter Is get deleted : ";
    getchar();
    char ans;
    outtextxy(240,340," Do you want to continue? ");
    ans=getche();
    if(ans=='y'||ans=='Y')
    {
      goto z;
    }
    else
    if(ans=='N'||ans=='n')
    {
      getchar();
      exit(1);
    }
  }

  case 6:
  {
    clearviewreport();
    outtextxy(250,360," The End Of Project");
    outtextxy(260,390,"\n \n \n \t \t \t Please Press Enter ");
    getchar();
    closegraph();
    exit(1);
  }


  default: goto z;

}

  };

  }
  }

It's like 3000 lines of code!

I only see 383 lines. Anyway, when I originally asked for code, I made sure to ask for a small but complete program that exhibits the problem. Some modicum of effort is required on your part to pare down the program to bare essentials so that it's easier to help you.

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.