Thread: need help !!!!!

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    24

    Question need help !!!!!

    can anybody tell me how can i call
    displayHeading();
    function for only first if statement, only once???


    Code:
    void displayCerteinDate ( )
    { //Find records with certain Date and Display all records in same Date.
    	system("cls");  //clear screen
    	int newday, newmounth, newyear;
    	bool flag = false;
    	cout<<"\nEnter the Date You want To Display (dd mm yyy): ";
    	cin>>newday>>newmounth>>newyear;
    	cin.get();
    
    	system("cls"); //clear screen
    	displayHeading();
    
    	for (int i=0; i<currentSize; i++)
    	if (AppList[i].appdate.day == newday &&
    	    AppList[i].appdate.mounth == newmounth &&
    	    AppList[i].appdate.year == newyear)
    	     {         
    	         flag = true;
    	         cout<<setw(20)<<AppList[i].name;
    	         cout<<setw(23)<<AppList[i].description;
    	         cout<<AppList[i].appdate.day;
    	         cout<<"/"<<AppList[i].appdate.mounth;
    	         cout<<"/"<<setw(14)<<AppList[i].appdate.year;
    	         cout<<AppList[i].time;
    	         cout<<endl<<endl;		
    	     }
    	 cin.get();
    
    	if(!flag) 
    	   {
    	       cout<<"\nThere are no Appointments on This Date!!!\n"<<endl;
    	       cout<<"Try with Different Date!!"<<endl;
    	       cin.get();  //give the user a chance to read the output data
    	   }  
    }
    Last edited by pczafer; 05-06-2009 at 12:42 AM.

  2. #2
    Not stupid, just stupider yaya's Avatar
    Join Date
    May 2007
    Location
    Earthland
    Posts
    204
    Code:
    for (int i=0; i<currentSize; i++)
    	if (AppList[i].appdate.day == newday &&
    	    AppList[i].appdate.mounth == newmounth &&
    	    AppList[i].appdate.year == newyear)
    	     {
    	         if ( i == 0 )
    	                  displayHeading();
    	         flag = true;
    	         cout<<setw(20)<<AppList[i].name;
    	         cout<<setw(23)<<AppList[i].description;
    	         cout<<AppList[i].appdate.day;
    	         cout<<"/"<<AppList[i].appdate.mounth;
    	         cout<<"/"<<setw(14)<<AppList[i].appdate.year;
    	         cout<<AppList[i].time;
    	         cout<<endl<<endl;		
    	     }
    Is that what you're asking?

  3. #3
    Registered User
    Join Date
    Apr 2009
    Posts
    24

    Wink

    Quote Originally Posted by yaya View Post
    Code:
    for (int i=0; i<currentSize; i++)
    	if (AppList[i].appdate.day == newday &&
    	    AppList[i].appdate.mounth == newmounth &&
    	    AppList[i].appdate.year == newyear)
    	     {
    	         if ( i == 0 )
    	         displayHeading();
    	         flag = true;
    	         cout<<setw(20)<<AppList[i].name;
    	         cout<<setw(23)<<AppList[i].description;
    	         cout<<AppList[i].appdate.day;
    	         cout<<"/"<<AppList[i].appdate.mounth;
    	         cout<<"/"<<setw(14)<<AppList[i].appdate.year;
    	         cout<<AppList[i].time;
    	         cout<<endl<<endl;		
    	     }
    Is that what you're asking?
    thaks this is exactly what was i looking for

Popular pages Recent additions subscribe to a feed