易截截图软件、单文件、免安装、纯绿色、仅160KB

C/C++——小编谈C语言函数那些事(6)

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1.       fclose函数
fclose函数的功能是关闭一个流,其用法是:int fclose(FILE *stream); 程序例子如下:
#include <string.h>
#include <stdio.h>
int main(void)
{
   FILE *fp;
   char buf[11] = "0123456789";
   /* create a file containing 10 bytes */
   fp = fopen("DUMMY.FIL", "w");
   fwrite(&buf, strlen(buf), 1, fp);
   /* close the file */
   fclose(fp);
   return 0;
}
2.       fcloseall函数
fcloseall函数的功能是关闭打开流,其用法是:int fcloseall(void); 程序例子如下:
#include <stdio.h>
int main(void)
{
   int streams_closed;
   /* open two streams */
   fopen("DUMMY.ONE", "w");
   fopen("DUMMY.TWO", "w");
   /* close the open streams */
   streams_closed = fcloseall();
   if (streams_closed == EOF)
      /* issue an error message */
      perror("Error");
   else
      /* print result of fcloseall() function */
      printf("%d streams were closed.\n", streams_closed);
   return 0;
}
3.       fcvt函数
fcvt函数的功能是把一个浮点数转换为字符串,其用法是:char *fcvt(double value, int ndigit, int *decpt, int *sign); 程序例子如下:
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
   char *string;
   double value;
   int dec, sign;
   int ndig = 10;
   clrscr();
   value = 9.876;
   string = ecvt(value, ndig, &dec, &sign);
   printf("string = %s     


相关文档:

C 宏定义的简单总结

 
我在写代码的时候喜欢使用宏,不仅使代码看起来整洁,而且用好了还能极大的减轻编码的工作量,但是如果使用不当的话,出了问题查找起来就就非常的难了,下面的总结大部分是从网上看到的,也有一些是我自己在工作中总结出来的。
宏使用中的常见的基础问题
1. 防止一个头文件被重复包含
   #ifndef BOD ......

C/C++/VC++ 变量命名规则

C/C++/VC++ 变量命名规则
是VC++的么?
4.变量风格
变量尽量采用匈牙利命名法,同时结合VC的原则;一般情况下,变量的取名方式为:
<scope><prefix><qualifier>
有关项目的全局变量必须用g_开始,类成员变量用m_,局部变量若函数较大则可考虑用l_用以显示说明其是局部变量。
前缀
类型
示例
g_ ......

C/C++中的日期和时间 time_t与struct tm转换

 摘要:
本文从介绍基础概念入手,探讨了在C/C++中对日期和时间操作所用到的数据结构和函数,并对计时、时间的获取、时间的计算和显示格式等方面进行了阐述。本文还通过大量的实例向你展示了time.h头文件中声明的各种函数和数据结构的详细使用方法。
关键字:UTC(世界标准时间),Calendar Time(日历时间),epoch ......

GNU C library 笔记1

内容:Introduction 和 Error Reporting
1. glibc 所实现全部或部分规范下的功能有
ISO C: The international standard for the C programming language.
POSIX: The ISO/IEC 9945 (aka IEEE 1003) standards for operating systems.
Berkeley Unix: BSD and SunOS.
SVID: The System V Interface Description.
X ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号