Home
menubar
rss_feed

Previous Reference C++ Reference <ctime> Next Reference




C++ Reference: asctime()





asctime()


Declaration

char* asctime(const struct tm* kqpTimePtr);

Description

This function takes in a time specification given as an instance of the "tm" data type and returns a char pointer to a character array that contains an ASCII text description of the time.

Example

#include <iostream>
#include <ctime>

int main() {
    using namespace std;

    time_t qTimeInTicks;
    time(&qTimeInTicks);

    tm* qpTimeStructPtr;
    qpTimeStructPtr = localtime(&qTimeInTicks);

    char* cpTimeText = 0;
    cpTimeText = asctime(qpTimeStructPtr);

    cout << "The time is " << cpTimeText << endl;

    return 0;
}


Output:








Previous Reference C++ Reference <ctime> Next Reference




Home | Reference | Play Games! | Blog | Forum | Site Map | Contact Us


shadow bottom image