By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,159 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,159 IT Pros & Developers. It's quick & easy.

time() function

P: 4
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!
Feb 22 '07 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 1,510
I assume you are attempting to concatenate three strings here
Expand|Select|Wrap|Line Numbers
  1. char * msg;
  2. msg = "NICK bot 3 "time()" 0 :IRC Services\r\n";
  3.  
try using strcat()
Expand|Select|Wrap|Line Numbers
  1.     time_t t;
  2.     char msg[100]="NICK bot 3 ";  // sufficent space for complete text;
  3.     time(&t);                     // get currect time
  4.     strcat(msg, ctime(&t));       // add time to msg
  5.  
when run msg contains something like
NICK bot 3 Thu Feb 22 06:39:50 2007
0 :IRC Services
Feb 22 '07 #2

P: 4
Thanks a lot, this is exactly what i want!
Feb 23 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.