Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Software (http://www.velocityreviews.com/forums/f6-software.html)
-   -   error in c++ progm (http://www.velocityreviews.com/forums/t694026-error-in-c-progm.html)

arc 08-07-2009 04:36 PM

error in c++ progm
 
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();
}

SomeOneHackedMyName 08-29-2009 01:30 AM

I'm new to C++, that shows in the console format right? And what does that code do if you'd share please? :)

technoplume 09-09-2009 04:14 PM

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.


All times are GMT. The time now is 02:28 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57