找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 1022|回复: 5

我不太懂这些头文件和库函数,可以帮我看看吗?

[复制链接]
发表于 2009-10-31 01:20:56 | 显示全部楼层 |阅读模式 IP:江苏扬州
朋友给的一个“到时间会发出声音”程序,如下:
#include <stdio.h> #include <time.h> #include <iostream.h> #include <conio.h> #include <dos.h>
void Make_Sound() { while(!kbhit()) { sound(200); delay(100); nosound(); } }
int main() { struct time t; int hour,min,sec; gettime(&t); printf("The current time is: %2d:%02d:%02d\n", t.ti_hour, t.ti_min, t.ti_sec); cout<<"now set hour:"<<endl; cin>>hour; cout<<"now set minute:"<<endl; cin>>min; cout<<"now set second:"<<endl; cin>>sec; while(1) { gettime(&t); if(hour==(int)t.ti_hour&&min==(int)t.ti_min&&sec==(int)t.ti_sec) break; }; Make_Sound(); return 0; }
发表于 2009-10-31 01:20:56 | 显示全部楼层 IP:江苏扬州
我把它修改为C++程序,但是自己就是不懂这些应该是在C里的头文件和库函数怎么办???
错误如下:
error C2065: 'sound' : undeclared identifier
error C2065: 'delay' : undeclared identifier
error C2065: 'nosound' : undeclared identifier
error C2065: 'gettime' : undeclared identifier
我想问:C里的头文件都要带".h"的后缀,那么在C++里是不是也要带".h"后缀???
程序如下:
#include"time.h"// 除了iostream外,其他C里的头文件怎么弄为C++里的头文件 #include"iostream" #include"conio.h" #include"dos.h" using namespace std; struct time{ int hours; int mins; int secs; }t; void MakeSound(){//制造声音的程序 while(!kbhit()){ sound(200);//是什么意思啊?我不懂 delay(100);//是什么意思啊? nosound();//是什么意思啊? }//while }//Make_Sound int main(){ int hour,min,sec,endFlag; gettime(&t);//是不是得到当前的时间并能够输入到 t 中的小时,分,和秒中??? //以下是先输出当前时间 //然后输入到什么时候发出声音的时间 cout<<endl<<"The current time is:"<<t.hours<<":"<<t.mins<<":"<<t.secs; cout<<endl<<endl<<"Now set hour:"; cin>>hour; cout<<endl<<endl<<"Now set minute:"; cin>>min; cout<<endl<<endl<<"Now set second:"; cin>>sec; //显示当前时间并设置时间点程序结束 while(1){//一个死循环,只有到了发声时间才会终止循环 gettime(&t);//是不是不断获得当前时间并修改结构体 t 里的内容??? if(hour==(int)t.hours&&min==(int)t.mins&&sec==(int)t.secs)//这些类型转换对了吗??? break; }//while MakeSound(); cout<<endl<<"End?OK,please press 1 "<<endl;//避免程序结果看不到 cin>>endFlag; return 0; }//main
回复

使用道具 举报

发表于 2009-10-31 01:20:57 | 显示全部楼层 IP:江苏扬州
再写一句,谁可以提供一些C++的函数使用手册啊!
看程序看得我要吐血啊~~~~~~~~~~~~~
回复

使用道具 举报

发表于 2009-10-31 01:20:58 | 显示全部楼层 IP:江苏扬州
http://www.ggv.com.cn/forum/clib/clib.html
回复

使用道具 举报

发表于 2009-10-31 01:20:59 | 显示全部楼层 IP:江苏扬州
你以上所写并非 C,C++ 标准库函数。我给他起个名称,称为第三方开发库函数,所以当你用 VC, 或Dev 来编译程序时会出错。包括那个WinIDE 也并非 standard c,c++ library . 你必须下载他的库函数软件包,方能编译,运行。
下面那个连接你看看
http://www.cplusplus.com/ref/
回复

使用道具 举报

发表于 2009-11-3 17:05:07 | 显示全部楼层 IP:越南
我刚来~~~嘿嘿~~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 17:23 , Processed in 0.454323 second(s), 15 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表