-3

Why does the compiler not recognize some of the functions of a library? I have enclosed the <ctime> library in Qt but does not recognize its functions. why? and how can I solve my problem?

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
Pasha
  • 73
  • 1
  • 2

1 Answers1

0

ofcourse compiler recognizes libs when they are properly included, functions are properly used (namespaces enclosed etc)

this example shows how to use a ctime lib to print the actual date: Note that the function time is enclosed in the namespace std therefore std::time(...) is a valid call

#include "mainwindow.h"
#include <QApplication>
#include <ctime>
#include <iostream>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    std::time_t result = std::time(nullptr);
    std::cout << "x: "<< std::ctime(&result);
    return a.exec();
}
ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97