View Single Post
  #7   Spotlight this post!  
Unread 19-02-2013, 21:17
mmavipc mmavipc is offline
Registered User
FRC #1622
 
Join Date: Jan 2012
Location: California
Posts: 6
mmavipc is an unknown quantity at this point
Re: Printing to a text file

Quote:
Originally Posted by mrklempae View Post
Thanks everyone! Everything seems to be working perfectly now, and we're on to the next problem. For some reason, when we try to read the data from the file using getline (which looks fine when we FTP it), we get the error
Code:
error: no matching function for call to `getline(std::ifstream&, int&)'
This is the actual code we're using to read the lines:
Code:
		if (counter <= 1500)
		{
		        if (Timer::GetPPCTimestamp() >= waitTimeout) //State machine  :D
			{
				//if ((!left.eof())&&(!right.eof()))
				//{
					rightval = std::getline(right, counter); //name of text file
                                        driverStationLCD->PrintfLine((DriverStationLCD::Line) 0, "%f", rightval);
                                        driverStationLCD->PrintfLine((DriverStationLCD::Line) 1, "%f", counter);
					driverStationLCD->UpdateLCD();
					counter++;
					waitTimeout += 0.01;
				//}
			}
Is this just a cRIO compatibility problem? We can get very similar code to run properly on a computer.
getline takes an istream and a string. You're going to have to get the string and then use something like a stringstream to transfer it to rightval.

Code:
std::string strTemp;
std::getline(istream, strTemp);
std::stringstream ss;
ss << strTemp;
ss >> rightval;
Reply With Quote