易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : c++

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");
   ......

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");
   ......

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

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1.       fgetc函数
fgetc函数的功能是从流中读取字符,其用法是:int fgetc(FILE *stream); 程序例子如下:
#include <string.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
   FILE *stream;
   char string[] = "This is a test";
   char ch;
   /* open a file for update */
   stream = fopen("DUMMY.FIL", "w+");
   /* write a string into the file */
   fwrite(string, strlen(string), 1, stream);
   /* seek to the beginning of the file */
   fseek(stream, 0, SEEK_SET);
   do
   {
      /* read a char from the file */
      ch = fgetc(stream);
      /* display the character */
   &nb ......

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

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1.       fgetc函数
fgetc函数的功能是从流中读取字符,其用法是:int fgetc(FILE *stream); 程序例子如下:
#include <string.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
   FILE *stream;
   char string[] = "This is a test";
   char ch;
   /* open a file for update */
   stream = fopen("DUMMY.FIL", "w+");
   /* write a string into the file */
   fwrite(string, strlen(string), 1, stream);
   /* seek to the beginning of the file */
   fseek(stream, 0, SEEK_SET);
   do
   {
      /* read a char from the file */
      ch = fgetc(stream);
      /* display the character */
   &nb ......

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

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
 
1.       gcvt函数
 
gcvt函数的功能是把浮点数转换成字符串,其用法是:char *gcvt(double value, int ndigit, char *buf);程序例子如下:
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
   char str[25];
   double num;
   int sig = 5; /* significant digits */
   /* a regular number */
   num = 9.876;
   gcvt(num, sig, str);
   printf("string = %s\n", str);
   /* a negative number */
   num = -123.4567;
   gcvt(num, sig, str);
   printf("string = %s\n", str);
   /* scientific notation */
   num = 0.678e5;
   gcvt(num, sig, str);
   printf("string = %s\n", str);
   return(0);
}
2.      getcr函数 ......

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

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
 
1.       gcvt函数
 
gcvt函数的功能是把浮点数转换成字符串,其用法是:char *gcvt(double value, int ndigit, char *buf);程序例子如下:
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
   char str[25];
   double num;
   int sig = 5; /* significant digits */
   /* a regular number */
   num = 9.876;
   gcvt(num, sig, str);
   printf("string = %s\n", str);
   /* a negative number */
   num = -123.4567;
   gcvt(num, sig, str);
   printf("string = %s\n", str);
   /* scientific notation */
   num = 0.678e5;
   gcvt(num, sig, str);
   printf("string = %s\n", str);
   return(0);
}
2.      getcr函数 ......

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

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1.     harderr函数
harderr函数的功能是建立一个硬件错误处理程序,其用法是:void harderr(int (*fptr)());程序例子如下:
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#define IGNORE  0
#define RETRY   1
#define ABORT   2
int buf[500];
static char *err_msg[] = {
    "write protect",
    "unknown unit",
    "drive not ready",
    "unknown command",
    "data error (CRC)",
    "bad request",
    "seek error",
    "unknown media type",
    "sector not found",
    "printer out of paper",
    "write fault",
    "read fault",
    "general failure",
    "reserved", ......

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

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1.     harderr函数
harderr函数的功能是建立一个硬件错误处理程序,其用法是:void harderr(int (*fptr)());程序例子如下:
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#define IGNORE  0
#define RETRY   1
#define ABORT   2
int buf[500];
static char *err_msg[] = {
    "write protect",
    "unknown unit",
    "drive not ready",
    "unknown command",
    "data error (CRC)",
    "bad request",
    "seek error",
    "unknown media type",
    "sector not found",
    "printer out of paper",
    "write fault",
    "read fault",
    "general failure",
    "reserved", ......

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

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
 
1. initgraph函数
initgraph函数是初始化图形系统,其用法为:void far initgraph(int far *graphdriver, int far *graphmode,char far *pathtodriver); 程序例子如下:
include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
    int gdriver = DETECT, gmode, errorcode;
    initgraph(&gdriver, &gmode, "");
     errorcode = graphresult();
   if (errorcode != grOk)   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1);         
   }
     line(0, 0, g ......

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

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
 
1. initgraph函数
initgraph函数是初始化图形系统,其用法为:void far initgraph(int far *graphdriver, int far *graphmode,char far *pathtodriver); 程序例子如下:
include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
    int gdriver = DETECT, gmode, errorcode;
    initgraph(&gdriver, &gmode, "");
     errorcode = graphresult();
   if (errorcode != grOk)   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1);         
   }
     line(0, 0, g ......

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

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
 
1. kbhit函数
 
kbhit函数是检查当前按下的键,其用法为:int kbhit(void);程序例子如下:
#include <conio.h>
int main(void)
{
   cprintf("Press any key to continue:");
   while (!kbhit()) /* do nothing */ ;
   cprintf("\r\nA key was pressed...\r\n");
   return 0;
}
2. keep函数
 
keep函数是退出并继续驻留,其用法为:void keep(int status, int size);程序例子如下:
#include <dos.h>
#define INTR 0x1C
#define ATTR 0x7900
extern unsigned _heaplen = 1024;
extern unsigned _stklen  = 512;
void interrupt ( *oldhandler)(void);
void interrupt handler(void)
{
   unsigned int (far *screen)[80];
   static int count;
   screen = MK_FP(0xB800,0);
   count++;
   count %= 10;
   screen[0][79] = count + '0' + ATTR; ......

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

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
 
1. kbhit函数
 
kbhit函数是检查当前按下的键,其用法为:int kbhit(void);程序例子如下:
#include <conio.h>
int main(void)
{
   cprintf("Press any key to continue:");
   while (!kbhit()) /* do nothing */ ;
   cprintf("\r\nA key was pressed...\r\n");
   return 0;
}
2. keep函数
 
keep函数是退出并继续驻留,其用法为:void keep(int status, int size);程序例子如下:
#include <dos.h>
#define INTR 0x1C
#define ATTR 0x7900
extern unsigned _heaplen = 1024;
extern unsigned _stklen  = 512;
void interrupt ( *oldhandler)(void);
void interrupt handler(void)
{
   unsigned int (far *screen)[80];
   static int count;
   screen = MK_FP(0xB800,0);
   count++;
   count %= 10;
   screen[0][79] = count + '0' + ATTR; ......
总记录数:969; 总页数:162; 每页6 条; 首页 上一页 [115] [116] [117] [118] 119 [120] [121] [122] [123] [124]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号