易截截图软件、单文件、免安装、纯绿色、仅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/C++中的日期和时间 time_t与struct tm转换

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

链表的基本操作(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/C++ 常见面试题

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

c va系列宏的基本用法

 va系列宏的用法的一般步骤:
 vsptr(char *format, ...)  //切记此处的格式
 {
    va_list argptr;
    va_start(argptr, format); //使得argptr指向以format开头的存储空间
    va_arg(argptr, type);  //取传递的参数
    ......

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号