Thread: Help - where am I screwing up/

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    7

    Question Help - where am I screwing up/

    This is for final project and this is last part that needs completed, I don't understand why its giving me problems. It is fine except for this one part of the code.

    Code:
    system("cls");
    	system("color 8A");
    	char runAgain;
    	tripEntry travels[100];
    	int counter = 0;
    	
    	do
    	{
    		do
    		{
    			cout << "Enter the trip ID number: ";
    			cin >> travels[counter].ID;
    			cout << "Enter the distance traveled on " << travels[counter].ID << ":";
    			cin << travels[counter].distance;
    			cout << "Enter the amount you are reimbursed per mile." << endl << "     (I.E.  0.25 for 25 cents)     ";
    			cin >> travels[counter].reimburse;
    			cout << "Add another trip? [Y/N]  ";
    			cin >> runAgain;
    			counter++;
    			runAgain = toupper(runAgain);
    		}while(runAgain == 'Y');
    
    		system("cls");
    
    		print_Top();
    		cout << VTUBE << " Trip ID     Miles     $/Mile     Reimburstment " << VTUBE << endl;
    		print_Mid();
    		for (int count =0; count<counter;count++)
    			cout << VTUBE << setw(8) << travels[count].ID << setw(10) << travels[count].distance << setw(6) << "$" << setw(5) << travels[count].reimburse << setw(12) << "$" << setw(6) << travels[count].distance * travels[count].reimburse << setw(2) << VTUBE << endl;
    
    		print_Bottom();
    
    		cout << "Do you want to make another? ";
    		cin >> runAgain;
    		runAgain = toupper(runAgain);
    
    	}while (runAgain =='Y');
    I have tried making HANDLE's to send it out specifically.

    I have to use ifstream and ofstreams in another part of the program, but don't seem to have an impact on any other parts.

    The errors I get are:
    Error 32 error C2784: 'std::basic_ostream<_Elem,_Traits> &std:perator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    On which line does the error message relate to?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    7
    All of the ones with 'cout' and 'cin'.

  4. #4
    Registered User
    Join Date
    Feb 2003
    Posts
    596
    Fix this line:

    Code:
    			cin << travels[counter].distance;
    You have << where you should have >>

  5. #5
    Registered User
    Join Date
    Oct 2008
    Posts
    7

    Lightbulb Wow!

    I am not only stupefied that I missed that, but that it caused 55 errors. I shouldn't be too surprised since I have looked so hard it for as long as I did.

    I thank you for the 2nd pair of eyes, to look at it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Conversion to bool screwing up my + overloading
    By Sharke in forum C++ Programming
    Replies: 35
    Last Post: 06-25-2009, 03:44 AM
  2. Replies: 2
    Last Post: 06-06-2008, 10:10 AM
  3. My if statements are screwing up
    By gooey kablooey in forum C++ Programming
    Replies: 4
    Last Post: 03-19-2004, 11:32 AM
  4. Textures Screwing Up
    By Krak in forum Game Programming
    Replies: 2
    Last Post: 07-10-2003, 10:30 PM
  5. Replies: 4
    Last Post: 12-07-2002, 04:24 PM