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

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 */
      putch(ch);
   } while (ch != EOF);
   fclose(stream);
   return 0;
}
2.       fgetchar函数
fgetchar函数的功能是关闭打开流,其用法是:int fgetchar(void); 程序例子如下:
#include <stdio.h>
int main(void)
{
   char ch;
   /* prompt the user for input */
   printf("Enter a character followed by \
   <Enter>: ");
   /* read the character from stdin */
   ch = fgetchar();
   /* display what was read */
   printf("The character read is: '%c'\n",
          ch);
   return 0;
}
3.       fread函数
fread函数的功能是从一个流中读数据,其用法是:int fread(void *ptr, int size, int nitems, FILE *stream); 程序例子如下:
#include <string.h>
#include <stdio.h>
int main(void)
{
   FILE *stream;
   ch


相关文档:

链表的基本操作(c实现)

  
链表定义及操作的源文件:employee.h
//
#pragma once
#ifndef __EMPLOYEE_H__
#define __EMPLOYEE_H__
#include<stdio.h>
#include<malloc.h>
typedef struct employee{
int id;
int age;
int salary;
}EmpType;
typedef struct Node{
EmpType data;
struct Node *next;
}L ......

C语言连接mysql数据库,读取mysql内容

 //linux下编译g++ $(mysql_config --cflags)  ***.cpp  $(mysql_config --libs)
/*mysql数据库中表的内容
mysql> select * from maindb;
+------------------+---------+-------------+---------+----------+---------------------+---------------------+---------------------+------------------- ......

C/C++ 常见面试题

 
1.指针和引用有什么分别;如果传引用比传指针安全,为什么?如果我使用常量指针难道不行吗?
     (1) 引用在创建的同时必须初始化,即引用到一个有效的对象;而指针在定义的时候不必初始化,可以在定义后面的任何地方重新赋值.
     (2) 不存在NULL引用,引用必 ......

curl c api

 curl c api
关于Curl的介绍很多,这里不详细介绍,主要谈一下简单应用。
最近研究了一下Linux下的curl C API,curl c API的文档比较丰富,唯一就是查找起来,费些时间。Curl的C API和curl的PHP API,函数接口和作用大致相同,所以如果有PHP API使用经验应该很好理解。
1:CURLcode curl_global_init(long flags);函 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号