计算机C++

来源:百度知道 编辑:UC知道 时间:2024/05/28 05:44:21
/* Note:Your choice is C IDE */
#include "stdio.h"
#include "time.h"
#include "dos.h"
#include "conio.h"
#include "stdlib.h"

#define PI 3.14159
void showTime(int x, int y);
void main(void)
{
showTime(28,12);

}
void showTime(int x, int y)
{
time_t ltime;
clrscr(); //字符屏幕清屏
while(!kbhit())
{
time(<ime); //读取系统时间,在于长整型变量ltime中
gotoxy(x,y); //光标移动到屏幕折(x,y)处
printf(ctime(<ime));//转换并显示日期和时间
delay(500); //延时500ms
}
}
有什么语法错误

1,读取系统时间,应该调用转进去的是ltime的地址。
2,printf用得不对,

#include "stdio.h"
#include "time.h"
#include "dos.h"
#include "conio.h"
#include "stdlib.h"

#define PI 3.14159 /*******-这一句没有用到--********/
void showTime(int x, int y);
void main(void)
{
showTime(28,12);

}
void showTime(int x, int y)
{
time_t ltime;
clrscr(); /*字符屏幕清屏*/
while(!kbhit())
{
time(& ltime); /********-----读取系统时间,在于长整型变量ltime中----********/
gotoxy(x,y); /*光标移动到屏幕折(x,y)处*/
printf("%s",ctime(& ltime));/********---转换并显示日期和时间---*******/
delay(500); /*延时500ms*/
}
}