0

hello, I'm almost done it, but I'm lost in the huge forest of c++...
so, here's my code:

#include <iostream>
#include <fstream>
#include <time.h>
#include <stdio.h>
using namespace std;

int gettime()
{
    time_t rawtime;
  struct tm * timeinfo;

  time ( &rawtime );
  timeinfo = localtime ( &rawtime );
 
  
 
}

int main () {
    
  ofstream failas;
  failas.open ("logas.txt", ios::out | ios::app);
  gettime();
  failas <<  asctime (timeinfo) ;
  failas.close();
  
  return 0;
}

can anyone say, where I'm wrong? THank you very much :)

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by marrkee
0

Compare and contrast:

#include <iostream>
#include <fstream>
#include <time.h>
#include <stdio.h>
using namespace std;

tm *gettime()
{
    time_t rawtime;

    time(&rawtime);
    
    return localtime(&rawtime);
}

int main()
{
    cout<<  asctime(gettime());
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.