随笔分类 -  C/C++

摘要:File OperationsFormatted OutputFormatted InputCharacter Input and Output FunctionsDirect Input and Output FunctionsFile Positioning FunctionsError Functions 阅读全文
posted @ 2013-03-22 11:12 freewater 阅读(181) 评论(0) 推荐(0) 编辑
摘要:The header <limits.h> defines constants for the sizes of integral types.The values below are acceptable minimum magnitudes; larger values may beused.CHAR_BIT 8 bits in a charCHAR_MAX UCHAR_MAX orSCHAR_MAXmaximum value of charCHAR_MIN 0 or SCHAR_MIN maximum value of charINT_MAX 32767 maximum va 阅读全文
posted @ 2013-03-21 17:00 freewater 阅读(353) 评论(0) 推荐(0) 编辑
摘要:The header <time.h> declares types and functions for manipulating date and time. Somefunctions process local time, which may differ from calendar time, for example because of timezone. clock_t and time_t are arithmetic types representing times, and struct tm holds thecomponents of a calendar t 阅读全文
posted @ 2013-03-21 15:00 freewater 阅读(388) 评论(0) 推荐(0) 编辑
摘要:9 Signals: <signal.h>The header <signal.h> provides facilities for handling exceptional conditions that arise duringexecution, such as an interrupt signal from an external source or an error in execution.void (*signal(int sig, void (*handler)(int)))(int)signal determines how subsequent s 阅读全文
posted @ 2013-03-21 14:55 freewater 阅读(272) 评论(0) 推荐(0) 编辑
摘要:The declarations in <setjmp.h> provide a way to avoid the normal function call and returnsequence, typically to permit an immediate return from a deeply nested function call.int setjmp(jmp_buf env)The macro setjmp saves state information in env for use by longjmp. The return iszero from a dire 阅读全文
posted @ 2013-03-21 14:52 freewater 阅读(300) 评论(0) 推荐(0) 编辑
摘要:7 Variable Argument Lists: <stdarg.h>The header <stdarg.h> provides facilities for stepping through a list of function arguments ofunknown number and type.Suppose lastarg is the last named parameter of a function f with a variable number ofarguments. Then declare within f a variable of t 阅读全文
posted @ 2013-03-21 14:33 freewater 阅读(266) 评论(0) 推荐(0) 编辑
摘要:The assert macro is used to add diagnostics to programs:void assert(int expression)If expression is zero whenassert(expression)is executed, the assert macro will print on stderr a message, such asAssertion failed: expression, file filename, line nnnIt then calls abort to terminate execution. The sou 阅读全文
posted @ 2013-03-21 14:30 freewater 阅读(150) 评论(0) 推荐(0) 编辑
摘要:5 Utility Functions: <stdlib.h>The header <stdlib.h> declares functions for number conversion, storage allocation, andsimilar tasks. double atof(const char *s)atof converts s to double; it is equivalent to strtod(s, (char**)NULL).int atoi(const char *s)converts s to int; it is equivalent 阅读全文
posted @ 2013-03-21 11:40 freewater 阅读(242) 评论(0) 推荐(0) 编辑
摘要:4 Mathematical Functions: <math.h>The header <math.h> declares mathematical functions and macros.The macros EDOM and ERANGE (found in <errno.h>) are non-zero integral constants that areused to signal domain and range errors for the functions; HUGE_VAL is a positive double value.A d 阅读全文
posted @ 2013-03-21 11:24 freewater 阅读(385) 评论(0) 推荐(0) 编辑
摘要:3 String Functions: <string.h>There are two groups of string functions defined in the header <string.h>. The first havenames beginning with str; the second have names beginning with mem. Except for memmove,the behavior is undefined if copying takes place between overlapping objects. Comp 阅读全文
posted @ 2013-03-21 11:17 freewater 阅读(416) 评论(0) 推荐(0) 编辑
摘要:2 Character Class Tests: <ctype.h>The header <ctype.h> declares functions for testing characters. For each function, theargument list is an int, whose value must be EOF or representable as an unsigned char, andthe return value is an int. The functions return non-zero (true) if the argume 阅读全文
posted @ 2013-03-21 09:37 freewater 阅读(199) 评论(0) 推荐(0) 编辑
摘要:1.7 Error FunctionsMany of the functions in the library set status indicators when error or end of file occur. Theseindicators may be set and tested explicitly. In addition, the integer expression errno (declaredin <errno.h>) may contain an error number that gives further information about the 阅读全文
posted @ 2013-03-20 22:57 freewater 阅读(226) 评论(0) 推荐(0) 编辑
摘要:1.6 File Positioning Functionsint fseek(FILE *stream, long offset, int origin)fseek sets the file position for stream; a subsequent read or write will access databeginning at the new position. For a binary file, the position is set to offset charactersfrom origin, which may be SEEK_SET (beginning), 阅读全文
posted @ 2013-03-20 22:54 freewater 阅读(194) 评论(0) 推荐(0) 编辑
摘要:1.5 Direct Input and Output Functionssize_t fread(void *ptr, size_t size, size_t nobj, FILE *stream)fread reads from stream into the array ptr at most nobj objects of size size. freadreturns the number of objects read; this may be less than the number requested. feofand ferror must be used to determ 阅读全文
posted @ 2013-03-20 22:50 freewater 阅读(215) 评论(0) 推荐(0) 编辑
摘要:1.4 Character Input and Output Functionsint fgetc(FILE *stream)fgetc returns the next character of stream as an unsigned char (converted to anint), or EOF if end of file or error occurs.char *fgets(char *s, int n, FILE *stream)fgets reads at most the next n-1 characters into the array s, stopping if 阅读全文
posted @ 2013-03-20 22:49 freewater 阅读(328) 评论(0) 推荐(0) 编辑
摘要:Formatted InputThe scanf function deals with formatted input conversion.int fscanf(FILE *stream, const char *format, ...)fscanf reads from stream under control of format, and assigns converted values throughsubsequent arguments, each of which must be a pointer. It returns when format is exhausted.fs 阅读全文
posted @ 2013-03-20 22:47 freewater 阅读(197) 评论(0) 推荐(0) 编辑
摘要:Formatted OutputThe printf functions provide formatted output conversion.int fprintf(FILE *stream, const char *format, ...)fprintf converts and writes output to stream under the control of format. The return valueis the number of characters written, or negative if an error occurred.int printf(const 阅读全文
posted @ 2013-03-20 22:32 freewater 阅读(201) 评论(0) 推荐(0) 编辑
摘要:File OperationsThe following functions deal with operations on files. The type size_t is the unsigned integraltype produced by the sizeof operator.FILE *fopen(const char *filename, const char *mode)fopen opens the named file, and returns a stream, or NULL if the attempt fails. Legalvalues for mode i 阅读全文
posted @ 2013-03-20 21:49 freewater 阅读(305) 评论(0) 推荐(0) 编辑
摘要:C/C++对时间的操作也有许多值得大家注意的地方。最近,在技术群中有很多网友也多次问到过C++语言中对时间的操作、获取和显示等等的问题。下面,在这篇文章中,笔者将主要介绍在C/C++中时间和日期的使用方法. 通过学习许多C/C++库,你可以有很多操作、使用时间的方法。但在这之前你需要了解一些“时间”和“日期”的概念,主要有以下几个: Coordinated Universal Time(UTC):协调世界时,又称为世界标准时间,也就是大家所熟知的格林威治标准时间(Greenwich Mean Time,GMT)。比如,中国内地的时间与UTC的时差为+8,也就是UTC+8。美国是UTC-5。 C 阅读全文
posted @ 2013-03-13 12:25 freewater 阅读(536) 评论(0) 推荐(0) 编辑
摘要:all_ofReturns true when a condition is present at each element in the given range.template<class InputIterator, class Predicate> bool all_of( InputIterator _First, InputIterator _Last, BinaryPredicate _Comp );any_ofReturns true when a condition is present at least once i... 阅读全文
posted @ 2013-03-11 17:12 freewater 阅读(213) 评论(0) 推荐(0) 编辑