求调用time.h实现显示时间的功能,请 看下错误。

loong0306 2014-06-20 11:56:20
有些迷茫了,求帮助

/*
测试系统时间输入输出。
2014年6月20日 23:29:30
-------------------------
功能:想达到调用windows.h中system中的time函数。
未实现。
*/

#include<iostream>
#include<math.h>
#include<string.h>
#include<windows.h>
#include<time.h>
using namespace std;

struct time /* Gets system time */
{
time_t t;
while(1)
{
time(&t);
Sleep(1000);
system("cls");
cout<<"Today's date and time:"<<endl<<ctime(&t)<<endl;
}

}tm;

int main( int argc, char *argv[] )
{
int year;int month;int day;
int h;int min; int s;
cout<<"系统时间日期 时间 显示。请用输入后加空格"<<endl;
cout<<"请输入系统日期:"<<endl;
cin>>year >>month >>day;
cout<<"请输入系统时间:"<<endl;
cin>>h >>min >>s;
printf("-----------------------------------------------------\n");
printf("- -\n");
printf("- 系统日期: -\n");
printf("- %d年%d月%d日 -\n",year,month,day);
printf("- 系统时间: -\n");
printf("- %d时%d分%d秒 -\n",h,min,s);
printf("- -\n");
printf("-----------------------------------------------------\n");
return 0;
}

...全文
242 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
我看你有戏 2014-06-22
  • 打赏
  • 举报
回复
引用 6 楼 u010957746 的回复:
[quote=引用 5 楼 henry3695 的回复:]


/*
	测试系统时间输入输出。
	2014年6月20日 23:29:30
	-------------------------
	功能:想达到调用windows.h中system中的time函数。
	未实现。
*/

#include<iostream>
#include<math.h>
#include<string.h>
#include<windows.h>
#include<time.h>
using namespace std;

struct mytime		/*   Gets   system   time   */	
{
	time_t t;
	mytime()
	{
		while(1)
		{
			Sleep(1000);
			system("cls");

			char szCurrentDateTime[32];     
			time_t nowtime;     
			struct tm* ptm;     
			time(&nowtime);     
			ptm = localtime(&nowtime);     
			sprintf(szCurrentDateTime, "%4d-%.2d-%.2d %.2d:%.2d:%.2d",     
				    ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday,     
				    ptm->tm_hour, ptm->tm_min, ptm->tm_sec); 


			cout<<"Today's date and time:"<<endl<<szCurrentDateTime<<endl; 
		}
	}
	
}tm;

int main( int argc, char *argv[] )
{
	struct mytime	 tt;
	
	return 0;
}


太谢谢了,我还学习到了指针的方法。3q[/quote] 要学习指针的一些用法,可以看看我做的C++视频,初学者会很有帮助 http://pan.baidu.com/s/1o6M8XCm 希望给有缘人一些帮助
loong0306 2014-06-22
  • 打赏
  • 举报
回复
引用 4 楼 czarten 的回复:
[quote=引用 3 楼 u010957746 的回复:] [quote=引用 2 楼 czarten 的回复:]

struct time        /*   Gets   system   time   */   
{
    time_t t;
    while(1)
    {
        time(&t);
        Sleep(1000);
        system("cls");
        cout<<"Today's date and time:"<<endl<<ctime(&t)<<endl; 
    }
}
这能通过编译?
求解。。[/quote] 你的main函数我来回看了好几遍,跟你上面这个struct毫无关联啊 所以struct里面写的任何东西当然不会起任何作用[/quote]看到了。。。。
loong0306 2014-06-22
  • 打赏
  • 举报
回复
引用 5 楼 henry3695 的回复:


/*
	测试系统时间输入输出。
	2014年6月20日 23:29:30
	-------------------------
	功能:想达到调用windows.h中system中的time函数。
	未实现。
*/

#include<iostream>
#include<math.h>
#include<string.h>
#include<windows.h>
#include<time.h>
using namespace std;

struct mytime		/*   Gets   system   time   */	
{
	time_t t;
	mytime()
	{
		while(1)
		{
			Sleep(1000);
			system("cls");

			char szCurrentDateTime[32];     
			time_t nowtime;     
			struct tm* ptm;     
			time(&nowtime);     
			ptm = localtime(&nowtime);     
			sprintf(szCurrentDateTime, "%4d-%.2d-%.2d %.2d:%.2d:%.2d",     
				    ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday,     
				    ptm->tm_hour, ptm->tm_min, ptm->tm_sec); 


			cout<<"Today's date and time:"<<endl<<szCurrentDateTime<<endl; 
		}
	}
	
}tm;

int main( int argc, char *argv[] )
{
	struct mytime	 tt;
	
	return 0;
}


太谢谢了,我还学习到了指针的方法。3q
我看你有戏 2014-06-22
  • 打赏
  • 举报
回复


/*
	测试系统时间输入输出。
	2014年6月20日 23:29:30
	-------------------------
	功能:想达到调用windows.h中system中的time函数。
	未实现。
*/

#include<iostream>
#include<math.h>
#include<string.h>
#include<windows.h>
#include<time.h>
using namespace std;

struct mytime		/*   Gets   system   time   */	
{
	time_t t;
	mytime()
	{
		while(1)
		{
			Sleep(1000);
			system("cls");

			char szCurrentDateTime[32];     
			time_t nowtime;     
			struct tm* ptm;     
			time(&nowtime);     
			ptm = localtime(&nowtime);     
			sprintf(szCurrentDateTime, "%4d-%.2d-%.2d %.2d:%.2d:%.2d",     
				    ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday,     
				    ptm->tm_hour, ptm->tm_min, ptm->tm_sec); 


			cout<<"Today's date and time:"<<endl<<szCurrentDateTime<<endl; 
		}
	}
	
}tm;

int main( int argc, char *argv[] )
{
	struct mytime	 tt;
	
	return 0;
}


你怎么了熊吉 2014-06-21
  • 打赏
  • 举报
回复

struct time        /*   Gets   system   time   */   
{
    time_t t;
    while(1)
    {
        time(&t);
        Sleep(1000);
        system("cls");
        cout<<"Today's date and time:"<<endl<<ctime(&t)<<endl; 
    }
}
这能通过编译?
你怎么了熊吉 2014-06-21
  • 打赏
  • 举报
回复
引用 3 楼 u010957746 的回复:
[quote=引用 2 楼 czarten 的回复:]

struct time        /*   Gets   system   time   */   
{
    time_t t;
    while(1)
    {
        time(&t);
        Sleep(1000);
        system("cls");
        cout<<"Today's date and time:"<<endl<<ctime(&t)<<endl; 
    }
}
这能通过编译?
求解。。[/quote] 你的main函数我来回看了好几遍,跟你上面这个struct毫无关联啊 所以struct里面写的任何东西当然不会起任何作用
loong0306 2014-06-21
  • 打赏
  • 举报
回复
引用 2 楼 czarten 的回复:

struct time        /*   Gets   system   time   */   
{
    time_t t;
    while(1)
    {
        time(&t);
        Sleep(1000);
        system("cls");
        cout<<"Today's date and time:"<<endl<<ctime(&t)<<endl; 
    }
}
这能通过编译?
求解。。
loong0306 2014-06-20
  • 打赏
  • 举报
回复
调用time不好用,求教。
下载代码方式:https://pan.quark.cn/s/28492da20c79 依据所提供的文件资料,本资源将系统地探讨FPGA(即现场可编程门阵列)的核心概念、其在视频图像技术领域的入门及进阶知识要点,以及图像处理算法的实现方法。此外,还将对VIPBoardBig这一特定FPGA开发板的详细资料和使用途径进行深入剖析。 FPGA的入门与进阶学习主要涉及以下核心内容: 1. FPGA的基础概念:FPGA是一种能够通过编程进行配置的集成电路,主要目的是达成硬件逻辑的可重构特性。该类芯片由大量的可配置逻辑模块(CLB)、输入输出模块(IOB)以及可编程互连资源共同构成。 2. FPGA开发板与相关套件:FPGA开发板是一种用于FPGA芯片学习和测试的硬件平台,通常配备有基础的外设设备,例如LED指示灯、按键开关、LCD显示屏、串口通信接口等。套件则通常包含硬件板卡、技术文档、相关资源,以及可能的软件工具和示例代码集。VIPBoardBig即为本教程选用的FPGA开发板,拥有特定的硬件配置和功能特性。 3. FPGA的开发流程:FPGA开发一般涉及硬件描述语言(HDL)的设计与仿真阶段,常用语言为Verilog或VHDL。随后,借助综合工具将设计蓝图转化为FPGA内部的逻辑网络,最终通过编程设备将配置文件传输至FPGA芯片中,从而实现设计的预期功能。 4. 外设开发与设计工作:涵盖LED显示控制、键盘驱动、LCD显示驱动、UART串口设计等基础外设的开发任务。这部分知识将引导学习者掌握如何在FPGA平台上管理和运用这些基础外设。 5. VGA驱动显示与字符显示测试:VGA(Video Graphics Array)是一种视频传输接口标准,能够支持640x480...
内容概要:本文系统阐述了企业在搭建官方知识库后如何通过“7步锚定法”实现GEO(生成式引擎优化)的落地,重点在于从知识库走向内容矩阵的战略升级。文章指出知识库仅为起点,真正的核心是让大模型“信任并推荐”企业内容。为此提出“一个主战场+多个品牌布局”的策略,强调需根据行业特性选择高商业流量的大模型(如豆包、文心一言、通义千问等),而非工具性模型(如ChatGPT、Claude)。通过业务场景画像、大模型流量测绘、采信逻辑拆解、内容架构设计、语义关键词埋点、信源建设与效果迭代七步法,构建高质量、高可信度的内容体系,并警惕“全模型覆盖、内容堆砌、一套内容通用、忽视第三方平台”四大误区。最终指出GEO本质是一场认知战,比拼的是对大模型逻辑与客户需的理解深度及长期主义投入。; 适合人群:已完成官方知识库搭建、希望提升AI引用率与获客效率的企业市场负责人、品牌运营、数字营销从业者及SEO/GEO优化相关人员。; 使用场景及目标:①指导企业科学选择主攻大模型并制定差异化内容策略;②构建符合大模型采信逻辑的高质量内容矩阵;③避免常见GEO落地误区,提升AI搜索下的品牌曝光与转化效果;④建立可持续优化的数据反馈闭环。; 阅读建议:建议结合自身行业特征与客户决策路径,逐步实践“7步法”,优先聚焦单一主战场打透,注重内容质量与第三方权威信源建设,坚持3-6个月持续投入以观察真实效果。

65,211

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧