error in c++ progm

Discussion in 'Software' started by arc, Aug 7, 2009.

  1. arc

    arc

    Joined:
    Aug 7, 2009
    Messages:
    1
    Location:
    u.p.
    hello please solve this prob (LValue required)


    void main()
    {

    int a=0;
    char *ptr[10]={" kanitkar","balagurushami","morishmano"};
    char str[20];
    clrscr();

    cout<<"enter name to search\n";
    cin>>str;

    for(a=0;a<3;a++)
    {

    if(!strcmp(str, *ptr[a]))

    {

    cout<<"book is found"<<endl;
    break;
    }
    ptr++;
    }
    if(a==3)
    cout<<"book not found";

    getch();
    }
     
    arc, Aug 7, 2009
    #1
    1. Advertising

  2. arc

    SomeOneHackedMyName

    Joined:
    Aug 29, 2009
    Messages:
    2
    I'm new to C++, that shows in the console format right? And what does that code do if you'd share please? :)
     
    SomeOneHackedMyName, Aug 29, 2009
    #2
    1. Advertising

  3. arc

    technoplume

    Joined:
    Jan 9, 2009
    Messages:
    55
    I haven't done C++ in some time but your trying to compare a string to a table to know if the book is there or not.

    I say your For loop should compare the result and return a value true or false by making a mask whit AND or OR fonction. It should return a 0 or 1 like a mask for bit. Then define the b has true of false and go to the if loop;


    if ( b = true )
    {cout<<"book is found"<<endl;
    break;}
    Else
    {cout<<"book is found"<<endl;
    break;}

    your current table only has 3 choice, but if it get bigger you have to modify 3 line. This way you scan the whole table and return T or F. Modifying only 2 line.
     
    Last edited: Sep 9, 2009
    technoplume, Sep 9, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TWljaGFlbA==?=

    Error using DOS window, ever seen this error?

    =?Utf-8?B?TWljaGFlbA==?=, Apr 15, 2004, in forum: Microsoft Certification
    Replies:
    1
    Views:
    611
    Marlin Munrow
    Apr 15, 2004
  2. =?Utf-8?B?RGF2aWQgRGF5?=

    DNS error or Time Out error following Broadband Upgrade

    =?Utf-8?B?RGF2aWQgRGF5?=, May 4, 2005, in forum: Microsoft Certification
    Replies:
    2
    Views:
    806
    BrainLock
    May 6, 2005
  3. =?Utf-8?B?VGVtcGxlUmluZ2xldHM=?=

    Windows Media Player 10 error "An Internal Application error has o

    =?Utf-8?B?VGVtcGxlUmluZ2xldHM=?=, Jun 27, 2005, in forum: Microsoft Certification
    Replies:
    1
    Views:
    3,183
    Don Carter
    Jun 27, 2005
  4. Ismaiel
    Replies:
    0
    Views:
    6,111
    Ismaiel
    Oct 26, 2004
  5. kanman
    Replies:
    0
    Views:
    5,466
    kanman
    Apr 25, 2009
Loading...

Share This Page