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 :)

Recommended Answers

All 2 Replies

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());
}

Narue, you are genus :), thank you very much :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.