Please help me debug this program

I have tried real hard but just can't seem to debug it. Whenever I try to compile it, the application (Turbo C++ 3 IDE) hangs with some exception error or something. Please help me to debug it. The program is a bit lengthy so I have uploaded it to another server and here's the link:
http://abhi.site-online.ws/programs/WORK.CPP

Thanks a lot!
Abhishek.

Comments

  • [b][red]This message was edited by MT2002 at 2006-1-19 18:2:30[/red][/b][hr]
    : I have tried real hard but just can't seem to debug it. Whenever I try to compile it, the application (Turbo C++ 3 IDE) hangs with some exception error or something. Please help me to debug it. The program is a bit lengthy so I have uploaded it to another server and here's the link:
    : http://abhi.site-online.ws/programs/WORK.CPP
    :
    : Thanks a lot!
    : Abhishek.
    :
    :
    [blue]
    There are some errors (synthatically) in your code..

    void operation::search_byname():[/blue][code]
    void operation::search_byname()
    {
    [blue]// code..[/blue]

    while(!a.eof())
    {
    pos++;
    a.read((char*) &z,sizeof(z));

    [red]
    //for(int i=0;((z.name[i]!=[b]''[/b])&&(z.name[i]!='o')&&(i<n));i++)
    [/red][green]
    for(int i=0;((z.name[i]!=[b]' '[/b])&&(z.name[i]!='o')&&(i<n));i++)
    [/green]

    [blue]
    // (Note the difference between '' and ' ')
    // Edit: I also noticed the use of 'o' instead '' (null)
    // Is this an intent?
    [/blue][/code]

    [blue]void operation::search_bycity()[/blue]

    [code]
    void operation::search_bycity()
    {
    [blue]//...[/blue]

    [red]
    //int n=strlen(city)[b];[/b] flag=0;[/red]
    [green]int n=strlen(city)[b],[/b] flag=0;[/green]

    [blue]// Note the use of semi (;) instead of comma (,)
    [/code]

    [blue]main()[/blue]
    [code]
    case 6: id_no=0;
    a.open(file,ios::in);
    a.seekg(0,ios::beg);

    [red]//while(a.read((char*)&b,sizeof(b))[/red]
    [green]while(a.read((char*)&b,sizeof(b)) ) ;[/green]
    //...
    [/code][blue]

    After fixing the above, the program compiled and executed
    fine for me.

    Hope this helps;
    ~mt2002[/blue]


  • Thanks for your help. No, the o was not meant to be so. It was meant to be a NULL character. Just a whole bunch of typos, though I still can't understand why the application was hanging for it.
    Once again thanks for your help.

    Abhishek.


    : [b][red]This message was edited by MT2002 at 2006-1-19 18:2:30[/red][/b][hr]
    : : I have tried real hard but just can't seem to debug it. Whenever I try to compile it, the application (Turbo C++ 3 IDE) hangs with some exception error or something. Please help me to debug it. The program is a bit lengthy so I have uploaded it to another server and here's the link:
    : : http://abhi.site-online.ws/programs/WORK.CPP
    : :
    : : Thanks a lot!
    : : Abhishek.
    : :
    : :
    : [blue]
    : There are some errors (synthatically) in your code..
    :
    : void operation::search_byname():[/blue][code]
    : void operation::search_byname()
    : {
    : [blue]// code..[/blue]
    :
    : while(!a.eof())
    : {
    : pos++;
    : a.read((char*) &z,sizeof(z));
    :
    : [red]
    : //for(int i=0;((z.name[i]!=[b]''[/b])&&(z.name[i]!='o')&&(i<n));i++)
    : [/red][green]
    : for(int i=0;((z.name[i]!=[b]' '[/b])&&(z.name[i]!='o')&&(i<n));i++)
    : [/green]
    :
    : [blue]
    : // (Note the difference between '' and ' ')
    : // Edit: I also noticed the use of 'o' instead '' (null)
    : // Is this an intent?
    : [/blue][/code]
    :
    : [blue]void operation::search_bycity()[/blue]
    :
    : [code]
    : void operation::search_bycity()
    : {
    : [blue]//...[/blue]
    :
    : [red]
    : //int n=strlen(city)[b];[/b] flag=0;[/red]
    : [green]int n=strlen(city)[b],[/b] flag=0;[/green]
    :
    : [blue]// Note the use of semi (;) instead of comma (,)
    : [/code]
    :
    : [blue]main()[/blue]
    : [code]
    : case 6: id_no=0;
    : a.open(file,ios::in);
    : a.seekg(0,ios::beg);
    :
    : [red]//while(a.read((char*)&b,sizeof(b))[/red]
    : [green]while(a.read((char*)&b,sizeof(b)) ) ;[/green]
    : //...
    : [/code][blue]
    :
    : After fixing the above, the program compiled and executed
    : fine for me.
    :
    : Hope this helps;
    : ~mt2002[/blue]
    :
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories