time() function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wellwellsti
    New Member
    • Feb 2007
    • 4

    time() function

    Hi all!

    I made a complete IRC Services application in Perl and now i'll want to do the same with C++.
    I use BSD Socket. After established the connection with the server, my services need to use the NICK commande to introduce a Service NickName like Chanserv.

    The syntax is like: NICK nickname numeric timestamp 0 :description

    I try to do:

    char * msg;
    msg = "NICK bot 3 "time()" 0 :IRC Services\r\n";
    send(sockfd, msg, len, 0);

    But an error occur during compulation about the () of time.

    I'll hope somebody could help me!

    Thanks in advance!
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    I assume you are attempting to concatenate three strings here
    Code:
    char * msg;
    msg = "NICK bot 3 "time()" 0 :IRC Services\r\n";
    try using strcat()
    Code:
        time_t t;
        char msg[100]="NICK bot 3 ";  // sufficent space for complete text;
        time(&t);                     // get currect time
        strcat(msg, ctime(&t));       // add time to msg
    when run msg contains something like
    NICK bot 3 Thu Feb 22 06:39:50 2007
    0 :IRC Services

    Comment

    • wellwellsti
      New Member
      • Feb 2007
      • 4

      #3
      Thanks a lot, this is exactly what i want!

      Comment

      Working...