摘要:
/* 功能: 获取当前系统时间 返回值: 0-成功,-1-失败 out: 保存返回的系统时间,格式由fmt决定 fmt: 0-返回:yyyy-mm-dd hh24:mi:ss, 1-返回:yyyy-mm-dd, 2-返回:hh24:mi:ss*/int getTime(char *out, int fmt) // 获取当前系统时间{ if(out == NULL) return -1; time_t t; struct tm *tp; t = time(NULL); tp = localtime(&t); if(fmt == 0) sprintf(out, "%2.2d-%2 阅读全文
摘要:
使用的是 Fedora 10 gcc编译下面程序 显示warning: the `gets' function is dangerous and should not be used.问题出在程序中使用了 gets Linux 下gcc编译器不支持这个函数,解决办法是使用 fgetsfgets()函数的基本用法为:fgets(char * s,int size,FILE * stream);/* 代码实现 */#include <stdio.h>int main ( ) { char name[20]; printf("\n 输入任意字符 : "); f 阅读全文