怎样下载门户网站,网站与域名,平台公司市场化转型,asp企业网站cmsstrtok函数是字符串函数库中的一个函数#xff0c;函数原型如下#xff1a;char *strtok(char s[], const char *delim);作用#xff1a;分解字符串为一组字符串。s为要分解的字符串#xff0c;delim为分隔符字符串。例如#xff1a;hello,hi:what?is!the.matter;函数原型如下char *strtok(char s[], const char *delim);作用分解字符串为一组字符串。s为要分解的字符串delim为分隔符字符串。例如hello,hi:what?is!the.matter; 把这串字符串传入strtok函数第二个delim写 ,:?!.; 这样就可以得到6个不同的子字符串。我们来写个例子验证一下就写分割时间的例子吧获取UTC时间如下#include #include #include int main(){char *wday[] {Sun, Mon, Tue, Wed, Thu, Fri, Sat};struct tm *p;char buf[100] {0};char *q ;time_t timep;time(timep); /*获得time_t结构的时间UTC时间*/p gmtime(timep); /*转换为struct tm结构的UTC时间*/sprintf(buf,%d/%d/%d-%s-%d:%d:%d\n,1900 p-tm_year, 1 p-tm_mon, p-tm_mday,wday[p-tm_wday], p-tm_hour, p-tm_min, p-tm_sec);printf(%s\n,buf);q strtok(buf,//--::);printf(q : %s\n,buf);while(1){q strtok(NULL ,//--::);if(q NULL)break ;printf(q : %s\n,q);}return 0;}运行结果2017/8/17-Thu-8:24:43q : 2017q : 8q : 17q : Thuq : 8q : 24q : 43总结以上就是这篇文章的全部内容了希望本文的内容对大家的学习或者工作具有一定的参考学习价值谢谢大家对脚本之家的支持。如果你想了解更多相关内容请查看下面相关链接