首页 > 其他分享 >C语言学习

C语言学习

时间:2022-09-18 10:11:58浏览次数:82  
标签:available No C语言 学习 file error type define

1.I/O: input &output 是一切实现的基础

  stdio标准IO

   sysio系统调用IO(文件IO)

如果一个系统环境下,2中io都可以使用,当然优先使用标准io

2.标准库函数都在man手册的第三章

 man手册的第七章是讲解机制的

stdio:FILE类类型贯穿始终

  读写操作的函数:

  fopen():打开一个流

  fclose():

字符读写:

  fgetc():

  fputc()

字符串读写:

  fgets():

  fputs():

二进制读写:

  fread():

  fwrite():

 

  printf():

  scanf():

  文件指针:

  fseek()

  ftell()

  rewind()

       缓存:

   fflush()

[root@SHSH-PuDong-BG-INT04 ~]# more /usr/include/asm-x86_64/errno.h 
#ifndef _X8664_ERRNO_H
#define _X8664_ERRNO_H
      宏名       宏值
#define EPERM            1      /* Operation not permitted */
#define ENOENT           2      /* No such file or directory */
#define ESRCH            3      /* No such process */
#define EINTR            4      /* Interrupted system call */
#define EIO              5      /* I/O error */
#define ENXIO            6      /* No such device or address */
#define E2BIG            7      /* Arg list too long */
#define ENOEXEC          8      /* Exec format error */
#define EBADF            9      /* Bad file number */
#define ECHILD          10      /* No child processes */
#define EAGAIN          11      /* Try again */
#define ENOMEM          12      /* Out of memory */
#define EACCES          13      /* Permission denied */
#define EFAULT          14      /* Bad address */
#define ENOTBLK         15      /* Block device required */
#define EBUSY           16      /* Device or resource busy */
#define EEXIST          17      /* File exists */
#define EXDEV           18      /* Cross-device link */
#define ENODEV          19      /* No such device */
#define ENOTDIR         20      /* Not a directory */
#define EISDIR          21      /* Is a directory */
#define EINVAL          22      /* Invalid argument */
#define ENFILE          23      /* File table overflow */
#define EMFILE          24      /* Too many open files */
#define ENOTTY          25      /* Not a typewriter */
#define ETXTBSY         26      /* Text file busy */
#define EFBIG           27      /* File too large */
#define ENOSPC          28      /* No space left on device */
#define ESPIPE          29      /* Illegal seek */
#define EROFS           30      /* Read-only file system */
#define EMLINK          31      /* Too many links */
#define EPIPE           32      /* Broken pipe */
#define EDOM            33      /* Math argument out of domain of func */
#define ERANGE          34      /* Math result not representable */
#define EDEADLK         35      /* Resource deadlock would occur */
#define ENAMETOOLONG    36      /* File name too long */
#define ENOLCK          37      /* No record locks available */
#define ENOSYS          38      /* Function not implemented */
#define ENOTEMPTY       39      /* Directory not empty */
#define ELOOP           40      /* Too many symbolic links encountered */
#define EWOULDBLOCK     EAGAIN  /* Operation would block */
#define ENOMSG          42      /* No message of desired type */
#define EIDRM           43      /* Identifier removed */
#define ECHRNG          44      /* Channel number out of range */
#define EL2NSYNC        45      /* Level 2 not synchronized */
#define EL3HLT          46      /* Level 3 halted */
#define EL3RST          47      /* Level 3 reset */
#define ELNRNG          48      /* Link number out of range */
#define EUNATCH         49      /* Protocol driver not attached */
#define ENOCSI          50      /* No CSI structure available */
#define EL2HLT          51      /* Level 2 halted */
#define EBADE           52      /* Invalid exchange */
#define EBADR           53      /* Invalid request descriptor */
#define EXFULL          54      /* Exchange full */
#define ENOANO          55      /* No anode */
#define EBADRQC         56      /* Invalid request code */
#define EBADSLT         57      /* Invalid slot */

#define EDEADLOCK       EDEADLK

#define EBFONT          59      /* Bad font file format */
#define ENOSTR          60      /* Device not a stream */
#define ENODATA         61      /* No data available */
#define ETIME           62      /* Timer expired */
#define ENOSR           63      /* Out of streams resources */
#define ENONET          64      /* Machine is not on the network */
#define ENOPKG          65      /* Package not installed */
#define EREMOTE         66      /* Object is remote */
#define ENOLINK         67      /* Link has been severed */
#define EADV            68      /* Advertise error */
#define ESRMNT          69      /* Srmount error */
#define ECOMM           70      /* Communication error on send */
#define EPROTO          71      /* Protocol error */
#define EMULTIHOP       72      /* Multihop attempted */
#define EDOTDOT         73      /* RFS specific error */
#define EBADMSG         74      /* Not a data message */
#define EOVERFLOW       75      /* Value too large for defined data type */
#define ENOTUNIQ        76      /* Name not unique on network */
#define EBADFD          77      /* File descriptor in bad state */
#define EREMCHG         78      /* Remote address changed */
#define ELIBACC         79      /* Can not access a needed shared library */
#define ELIBBAD         80      /* Accessing a corrupted shared library */
#define ELIBSCN         81      /* .lib section in a.out corrupted */
#define ELIBMAX         82      /* Attempting to link in too many shared libraries */
#define ELIBEXEC        83      /* Cannot exec a shared library directly */
#define EILSEQ          84      /* Illegal byte sequence */
#define ERESTART        85      /* Interrupted system call should be restarted */
#define ESTRPIPE        86      /* Streams pipe error */
#define EUSERS          87      /* Too many users */
#define ENOTSOCK        88      /* Socket operation on non-socket */
#define EDESTADDRREQ    89      /* Destination address required */
#define EMSGSIZE        90      /* Message too long */
#define EPROTOTYPE      91      /* Protocol wrong type for socket */
#define ENOPROTOOPT     92      /* Protocol not available */
#define EPROTONOSUPPORT 93      /* Protocol not supported */
#define ESOCKTNOSUPPORT 94      /* Socket type not supported */
#define EOPNOTSUPP      95      /* Operation not supported on transport endpoint */
#define EPFNOSUPPORT    96      /* Protocol family not supported */
#define EAFNOSUPPORT    97      /* Address family not supported by protocol */
#define EADDRINUSE      98      /* Address already in use */
#define EADDRNOTAVAIL   99      /* Cannot assign requested address */
#define ENETDOWN        100     /* Network is down */
#define ENETUNREACH     101     /* Network is unreachable */
#define ENETRESET       102     /* Network dropped connection because of reset */
#define ECONNABORTED    103     /* Software caused connection abort */
#define ECONNRESET      104     /* Connection reset by peer */
#define ENOBUFS         105     /* No buffer space available */
#define EISCONN         106     /* Transport endpoint is already connected */
#define ENOTCONN        107     /* Transport endpoint is not connected */
#define ESHUTDOWN       108     /* Cannot send after transport endpoint shutdown */
#define ETOOMANYREFS    109     /* Too many references: cannot splice */
#define ETIMEDOUT       110     /* Connection timed out */
#define ECONNREFUSED    111     /* Connection refused */
#define EHOSTDOWN       112     /* Host is down */
#define EHOSTUNREACH    113     /* No route to host */
#define EALREADY        114     /* Operation already in progress */
#define EINPROGRESS     115     /* Operation now in progress */
#define ESTALE          116     /* Stale NFS file handle */
#define EUCLEAN         117     /* Structure needs cleaning */
#define ENOTNAM         118     /* Not a XENIX named type file */
#define ENAVAIL         119     /* No XENIX semaphores available */
#define EISNAM          120     /* Is a named type file */
#define EREMOTEIO       121     /* Remote I/O error */
#define EDQUOT          122     /* Quota exceeded */

#define ENOMEDIUM       123     /* No medium found */
#define EMEDIUMTYPE     124     /* Wrong medium type */
#define ECANCELED       125     /* Operation Cancelled */
#define ENOKEY          126     /* Required key not available */
#define EKEYEXPIRED     127     /* Key has expired */
#define EKEYREVOKED     128     /* Key has been revoked */
#define EKEYREJECTED    129     /* Key was rejected by service */

#endif

 

3.gcc -E test.c -E表示预处理,凡是源码里面有#号的内容都是在预处理阶段进行处理

4.在man手册里面查看一个函数的时候,头文件有几个,一定要包含几个

5.errno:异常号

6.perror:打印系统异常信息,就是把异常号变成异常信息,perror能够自动关联全局变量errno

 perror("fopen()");这个是直接输出异常信息

  strerror(errno)就是把异常号变成异常信息

  fprintf(stderr,"fopen():%s\n",strerror(errno))

7.如果一格函数有互逆操作的函数,那么这个函数开辟的空间一定是在堆上的

8.用宏的目的,就是一改全改

9.puts是在控制台输出

10.设计原则

  谁打开,谁释放

  谁申请,谁释放

  一切皆文件

  是资源就有上限

11.stdin,stdout,stderr这个是三个标准流,默认是打开的

12.

标签:available,No,C语言,学习,file,error,type,define
From: https://www.cnblogs.com/miwaiwai/p/16703406.html

相关文章

  • C++学习笔记-day16
    1、模板......
  • 深度学习:计算性能
    1、命令式和符号式混合编程命令式编程,它使用编程语句改变程序状态:defadd(a,b):returna+bdeffancy_func(a,b,c,d):e=add(a,b)f=add(c,d)......
  • ML第24周学习小结
    本周收获总结一下本周学习内容:1、《深度学习》第七章:优化算法7.1优化与深度学习~7.8Adam算法......
  • ML-高级集成学习:混合
    ML-高级集成学习:混合混合混合与堆叠非常相似。它还使用基础模型将基础预测作为新特征提供,并在新特征上训练新元模型以提供最终预测。唯一的区别是元模型的训练是在一个......
  • SpringCloud学习笔记(二)——Eureka(注册中心)
    一、Eureka简介 二、Eureka快速入门2.1搭建Eureka-Server首先新建一个maven项目:   这里src删除掉就可以了。   在项目下新建一个module(maven类型的):......
  • Day3 java数组和方法的学习
    Day3Java方法什么是方法理解上,方法和C++的函数差不多,即实现某个功能语句块的集合,尽量保证一个方法只完成一个功能。命名规则,首字母小写后面新单词大写类似studentLe......
  • C语言结构体初始化例子
    #include<stdio.h>main(){structstudent{charno[6];charname[8];intscore;};structstudentab[10]={{......
  • 深度学习库 SynapseML for .NET 发布0.1 版本
    2021年11月微软开源一款简单的、多语言的、大规模并行的机器学习库SynapseML(以前称为MMLSpark),以帮助开发人员简化机器学习管道的创建。具体参见[1]微软深度学习库Synap......
  • 钱包助记词学习备录
    区块链课程:https://github.com/biquanlibai/blockchain-course原理:https://jinzhijun.cn/develop/1208https://jinzhijun.cn/develop/1198 钱包助记词之所以在不同的......
  • MarkDown学习
    Markdown学习#+空格=一级标题二级标题##+空格=二级标题三级标题###+空格=三级标题同理,往后每增加一级添加一个井号,最多支持六级字体Hello,World!前后两个*......