Sorry about the title, but I thought it would be interesting.
Here is my problem. I am supposed to convert a certain input into a desired output. The input is
2
201101190930 F76.4
201101191330 C16.3
The first number is the number of strings in the file. It then goes
YYYYMMDDHHMM
Year, month, day, hour, minutes, xtemp where x is F/C and the other is the temp.
This is supposed to be converted like so
24.67 C -- recorded on 01/19/2011 at 09:30
16.30 C -- recorded on 01/19/2011 at 13:30
I believe I know how to convert Fahrenheit to Celsius with a different function.
My problem is that I don't know how to make my string read the F76.4. I can read the other part and get that output, but when I implement the same string reading for the temperature, it says that my std is out of bounds.
Below is the code
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main()
{
...//the loop, declaration of input and the such
cin >> input;
string year(input, 0, 4);
string month(input 4, 2);
string day(input, 6, 2);
string hours(input, 8, 2);
string minutes(input, 10, 2);
string x(input, 13, 1);
string temp(input, 14, 2)
cout << x << temp;
cout << "-- recorded on " << month;
cout << "/" << day << "/" << year;
cout << " at " << hours << ":" << minutes;
cout << endl;
return 0;
}
I know you can just give me the answer, but I'd prefer if you can explain it to me. I don't want to cheat. This is my major and I have a passion for it, but I can not find this answer in my book. Please help!
Thank you :D