- Code: Select all
#include <stdlib.h>
#include <ctime>
#include <iostream>
#include <string>
#include <fstream>
long real_hours;
long hour;
int day;
int month;
using std::cout;
int main() //line 35
{
real_hours = (((time (NULL)) / 60) / 60);
cout << real_hours << "\n";
cout << real_hours - 303148<< "\n";
hour = real_hours - 303148;
cout << hour << "\n";
while (hour >= 240)
{
hour -= 240;
day += 10;
}
while (hour >= 24)
{
hour -= 24;
day += 1;
}
cout << "Time is: " << hour << "\n";
month = 8;
cout << "Day is:" << month << day + 1 << "\n";
}
int changebg() //line 57
{
string filename1;
string filename2; //line 60
int time1;
int time2;
char buffer[256];
ifstream settings ("settings.txt");
if (! settings.is_open()) //line 65
{
cout << "Error opening file"; exit (1);
}
while (! settings.eof() )
{ //line 70
settings.getline (buffer,100);
filename1 << buffer << endl;
settings.getline (buffer,100);
filename2 << buffer << endl;
settings.getline (buffer,100); //line 75
time1 << buffer << endl;
settings.getline (buffer,100);
time2 << buffer << endl;
}
cout << filename1 << "\n" << filename2 << "\n" << time1 << "\n" << time2 << "\n"; //line 80
}
And here's the errors:
- Code: Select all
main.cpp: In function `int changebg()':
main.cpp:59: error: `string' undeclared (first use this function)
main.cpp:59: error: (Each undeclared identifier is reported only once for each function it appears in.)
main.cpp:59: error: syntax error before `;' token
main.cpp:64: error: `ifstream' undeclared (first use this function)
main.cpp:64: error: syntax error before `(' token
main.cpp:65: error: `settings' undeclared (first use this function)
main.cpp:72: error: `filename1' undeclared (first use this function)
main.cpp:72: error: `endl' undeclared (first use this function)
main.cpp:74: error: `filename2' undeclared (first use this function)
main.cpp:76: error: invalid operands of types `int' and `char[256]' to binary `operator<<'
main.cpp:78: error: invalid operands of types `int' and `char[256]' to binary `operator<<'
main.cpp:81:4: warning: no newline at end of file
gmake: *** [main.o] Error 1
*** failed ***
