二、Input and output-2013-4-9

Input and output are not part of the C language itself。
 
一、Standard Input and Output
a、The symbolic constant EOF is defined in <stdio.h>. The value is typically -1, bus  tests should be written in terms of EOF so as to
      be independent of the specific  value.

b、"functions" like getchar and putchar in <stdio.h> and tolower in <ctype.h> are often macros, thus avoiding the overhead of a function call per character.

 
二、Formatted Output - printf
a、printf converts, formats, and prints its arguments on the standard output , It returns the number of characters printed
b、printf uses its first argument to decide how many arguments follow and what their type is.

 
三、Variable-length Argument Lists
a、The standard header <stdarg.h> contains a set of macro definitions that define how to step through an argument list.
b、The implementation of this header will vary from machine to machine, but the  interface it presents is uniform.
c、structure and operate
/* typedef struct {
          char *a0;       /* pointer to first homed integer argument */
         int offset;     /* byte offset of next parameter */
 } va_list;
*/
 typedef char *va_list;
 #define _INTSIZEOF(n)   ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
 #define va_start(ap,v)  ( ap = (va_list)&v + _INTSIZEOF(v) )
 #define va_arg(ap,t)    ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
 #define va_end(ap)      ( ap = (va_list)0 )


四、Formatted Input - Scanf
a、scanf reads characters from the standard input, interprets them according to the specification in format, and stores the results  
       through the remaining arguments.

b、the other arguments, each of which must be a pointer, indicate where the corresponding converted input should be stored.

c、There is also a function sscanf that reads from a string instead of the standard  input:
       int sscanf(char *string, char *format, arg1, arg2, ...)

d、The function ferror returns non-zero if an error occurred on the stream fp.
 
五、File Access
a、This pointer, called the file pointer, points to a structure that contains information about the file

b、The call to fopen in a program is
       fp = fopen(name, mode);
      The second argument is the mode, also a character string, which indicates how  one intends to use the file. Allowable modes   
   include read ("r"), write ("w"),  and append ("a").  If there is any error, fopen will return NULL.

c、the operating system environment is responsible for opening three files and providing pointers for them. These files are the
     standard input, the standard output, and the standard error; the corresponding file pointers are called   stdin, stdout, and stderr

d、Normally stdin is connected to the keyboard and stdout and stderr are connected to the screen, but stdin and stdout may be 
     redirected to files or pipes as described

e、fclose is the inverse of fopen, it breaks the connection between the file pointer and the external name that was established   by
     fopen, freeing the file pointer for  another file.

f、fclose is called automatically for each open file when a program terminates normally.
 
六、Error Handling - Stderr and Exit
a、Output written on stderr normally appears on the screen even if the standard output is redirected.
b、The argument of exit is available to whatever process called this one
c、exit calls fclose for each open output file, to flush out any buffered output.
d、Within main, return expr is equivalent to exit(expr). exit has the advantage that  it can be  called from other functions

 
七、Line Input and Output
a、fgets reads the next input line (including the newline) from file fp into the  character array line; at most maxline-1 characters will be
      read. The resulting line is terminated with '\0'.

b、Confusingly, gets deletes the terminating '\n', and puts adds it.

 
八、Storage Management
 The right way is to save whatever is needed before freeing: (list)
 for (p = head; p != NULL; p = q)
 {
  q = p->next;
  free(p);
 }
springboot052基于Springboot+Vue旅游管理系统毕业源码案例设计 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值