// absolute.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<iostream>
#include<string>

 using namespace std;




int _tmain(int argc, _TCHAR* argv[])
{
     

      int i=0, j=0,k=0,l=0;  string yes1;bool outcome;int u=0,v=0,w=0;
      string arr[4 ][4]={{"Name","Plot #", "Cost", "Address"}, {"john", "1121", "Rs.1000", "62 johar TOWN LAHORE"}, {"jonty", "1123", "Rs.100000", "56 model LAHORE"},{"bruce", "65", "Rs.20000", "55 model TOWN LAHORE"}};
	  
	  outcome=true;

	 
	

	  while(outcome==true)
	  {

	  string plotnumber="1"; string NameLandlord="1"; char plotnumberr[15]="1",NameLandlordd[15]="1";u=0,v=0,w=0; outcome=true;
      cout<<"To access info by name type 1 and press enter"<<endl<<endl;
      cout<<"To access info by #plot type 2 and press enter"<<endl;
	  cout<<endl;
      cin>>k;
	  

if(k==1)
{  
	cout<<endl;
	cout<<"enter the name of the landlord";
	cin>>NameLandlord;
	
	 for(int w=0;NameLandlord[w]!='\0';w++)
	 {
		 NameLandlordd[w]=NameLandlord[w];

		 
	 }
}
else

{    cout<<endl;
     cout<<"Enter plot number"<<endl;
     cin>>plotnumber;
	 for(int w=0;plotnumber[w]!='\0';w++)
	 {
		 plotnumberr[w]=plotnumber[w];

		 
	 }

	 
}	

while(i<4)
{ 
	
     j=0;
while(j<4)
{
	u=1;
	while(((plotnumberr[u]==arr[i][j][u])||(NameLandlordd[u]==arr[i][j][u]))&&((NameLandlordd[u]!='\0')&&(plotnumberr[u]!='\0')))
	{
    u++;

	
	if(((plotnumberr[u]!=arr[i][j][u])&&(plotnumberr[u]!='\0'))||((NameLandlordd[u]!=arr[i][j][u])&&(NameLandlordd[u]!='\0')))
	{
		v=2;
	}
	else if((NameLandlordd[u]=='\0')||(plotnumberr[u]=='\0'))
	{
		
		v=1; // Why does we never become 1 even when user enters a string matching to
		i=4;    the one in the array for example john or John?
	}
	}

if(((plotnumber==arr[i][j])&&(v==1))||((NameLandlord==arr[i][j])&&(v==1)))
{
	 cout<<endl;
     cout<<arr[0][0]<<"   ";
     cout<<arr[0][1]<<"   ";
     cout<<arr[0][2]<<"        ";
     cout<<arr[0][3]<<"   "<<endl<<endl;
     cout<<arr[i][0]<<"  ";
     cout<<arr[i][1]<<"   ";

     cout<<arr[i][2]<<"   ";
     cout<<arr[i][3]<<"   "<<endl;
     cout<<endl;
	 
}


	j++;


	


    


}

i++;

}
cout<<"You wanna keep going?";
cin>>yes1;
if(yes1=="yes")
{
	outcome=true;
	i=0;
}
else
{
	outcome=false;
}
	  } 
	  cout<<v;

       system("pause");
     return 0;
	 }

Why does v never become 1 even when user enters a string matching to the one in the array for example john or John?

Edited 4 Years Ago by hey.howdy: n/a

This article has been dead for over six months. Start a new discussion instead.