网络游戏开发 -C++ 程序设计

Click here to load reader

download 网络游戏开发 -C++ 程序设计

of 32

description

第 1 章 C++ 程序设计基础. 网络游戏开发 -C++ 程序设计. 第 3 章函数. 标准库函数的使用 函数重载 内联函数. 标准库函数 函数重载. 函数重载. 了解标准库函数 掌握函数重载. 第 3 章函数. 3.4 标准库函数的使用. C++ 语言提供了极为丰富的库函数。. 第 3 章函数. 3.4 标准库函数的使用. C 语言标准库中的各个函数,类型以及宏分别在以下标准头文件中说明: assert.h float.h math.h stdarg.h stdlib.h - PowerPoint PPT Presentation

Transcript of 网络游戏开发 -C++ 程序设计

  • 3

  • 33.4 C++

    ASCII()

  • 33.4 C

    assert.h float.h math.h stdarg.h stdlib.h ctype.h limits.h setjmp.h stddef.h string.h errno.h locale.h signal.h stdio.h time.h

    #include

  • 33.4 3.4.1

    FILE/FILEC++1.

  • 33.4 3.4.1 FILE * fopen(const char * filename, const char* mode);1.

    "r""w""a""r+""w+""a+"

  • 33.4 3.4.1 int fclose(FILE * stream);int rename(const char * oldname, const char *newname);int remove(const char* filename);1.

  • 33.4 3.4.1 int fscanf(FILE * stream, const char * format, ...);fscanf2. %sa fox fall into water%f3.25%d7661 20 66 6f 78 2066 61 6c 6c 200x0000004c00 00 50 40formatint scanf(const char* format, ...);

  • 33.4 3.4.1 int fgetc(FILE * stream);fgetc3. char * fgets(char *s, int n, FILE *stream);unsigned charstreamfgetsn-1sfgets

  • 33.4 3.4.1 int fputs(const char *s, FILE *stream);fputs3. int getc(FILE *stream);int getchar(void);char *gets(char *s);int putc(int c, FILE * stream);int putchar(int c);int puts(const char *s);int ungetc(int c , FILE * stream);unsigned charstream

  • 33.4 3.4.1 size_t fread(void *ptr, size_t size size_t nobj, FILE *stream);fread4. nobjsizeptrsize_t fwrite(const void *ptr, size_t size, size_t nobj, FILE *stream);fwriteptrnobjsizestream

  • 33.4 3.4.1 int fseek(FILE *stream, long offset, int origin);fseek5. fseekoffsetorigin SEEK_SETSEEK_CURSEEK_END61 20 66 6f 78 20 66 61 6c 6c 20fread/fwrite/

  • 33.4 3.4.1 long ftell(FILE *stream);ftell stream5. void rewind(FILE *stream);rewind fseek(fp, 0L, SEEK_SET)clearerr(fp)

  • 33.4 3.4.1 6. void clearerr(FILE *stream);int feof(FILE *stream);int ferror(FILE *stream);void perror(const char *s);

  • 33.4 3.4.2 isalnum(c);//isalpha(c) isdigit(c)isalpha(c);//isupper(c) islower(c)iscntrl(c);//cisdigit(c);//cisgraph(c);//cislower(c);//cisprint(c);//cispunct(c);//c

  • 33.4 3.4.2 isspace(c);// cisupper(c);//cisxdigit(c);//c7ASCII0x20( )0x7E('`')0(NUL)0x1F(US) 0x7F(DEL)int tolower(int c); //cint toupper(int c);//c

  • 33.4 3.4.3 1. strchar *strcpy(char *strDestination, const char *strSource ); char *strncpy(char *strDest,const char *strSource,size_t count);char *strcat(char *strDestination, const char *strSource);char *strncat(char *strDest, const char *strSource, size_t count);int strcmp(const char *string1,const char *string2);int strncmp(const char *string1,const char *string2,size_t count );strmem

  • 33.4 3.4.3 1. str//stringcNULLchar *strchr(const char *string,int c);

    //stringstrCharSetsize_t strspn(const char *string, const char *strCharSet);

    //stringstrCharSetsize_t strcspn(const char *string,const char *strCharSet);

    //strCharSetstringchar *strpbrk(const char *string,const char *strCharSet);//char *strstr(const char *string,const char *strSearch );size_t strlen(const char *string );//char *strerror(int errnum);//strDelimitchar *strtok( char *strToken, const char *strDelimit );

  • 33.4 3.4.3 1. 2. memvoid *memcpy(void* dest,const void* src,size_t count );

    void *memmove(void* dest, const void* src, size_t count );

    int memcmp(const void* buf1, const void* buf2, size_t count );

    void *memset(void* dest, int c, size_t count );

  • 33.4 3.4.4

    sin(double x)xcos(double x)xtan(double x)xasin(double x)sin-1 x,[-/2/2]x[-11]acos(double x)cos-1 (x)[0, ] x[-11]atan(double x)tan-1 (x) [-/2/2]atan2(double y, double x)tan-1 (y/x)[-, ]sinh(double x)xcosh(double x)xtanh(double x)xexp(double x)ex log(double x)ln(x)x>0log10(double x)10log10(x)x>0pow(double x, double y)xyx=0y0x

  • 33.4 3.4.5 double atof(const char *s);int atoi(const char *s);long atol(const char *s);double strtod(const char *s, char **endp);long strtol(const char *s, char **endp, int base) unsigned long strtoul strtoul(const char* s, char **endp, int base);int rand(void);void srand(unsigned int seed);void *calloc(size_t nobj, size_t size);void *malloc(size_t size);void *realloc(void *p, size_t size);void free(void *p);

  • 33.4 3.4.5 3.4.6 void assertint;void abort(void);void exit(int status);int atexit(void (*fcn)(void));int system(const char *s);char *getenv(const char *name)void bsearch (const void *key, const void *base, size_t n,size_t size, int (*cmp)(const void *keyval, const void *datum) );void qsort(void *base,size_t n, size_t size,int (*cmp)(const void *, const void *));int abs(int n)long labs(long n)div_t div(int num, int denom)ldiv_t ldiv(long num, long denom)

  • 33.4 3.4.7 type va_arg(va_list ap,;void va_end(va_list ap);3.4.8 time_t time(time *tp)char *asctime(const struct tm *tp);char *ctime(const time_t *tp);struct tm *gmtime(const time_t *tp);struct tm *localtime(const time_t *tp)

    int tm_sec(0,59)int tm_min(0,59)int tm_hour023int tm_mday131int tm_mon1011int tm_year1900int tm_wday06int tm_yday0365int tm_isdst

  • 33.4 3.4.7

    CHAR_BIT8charCHAR_MAXSCHAR_MAXcharCHAR_MIN0,SHAR_MINcharINT_MAX+32767intINT_MIN-32767intLONG_MAX+2147483647longLONG_MIN-2147483647longSCHAR_MAX+127signed charSCHAR_MIN-127signed charSHRT_MAX+32767shortSHRT_MIN-32767shortUCHAR_MAX255unsigned charUINT_MAX65535unsigned intULONG_MAX4294967295unsigned longUSHRT_MAX65535unsigned short

  • 33.5 void EatBeef(); void EatFish(); void EatChicken(); void Print(); // class A{ void Print(); // }

  • 33.5 void output(int x); // void output(float x); //

    // output(0.5); // output(int(0.5)); // 0output(float(0.5)); // 0.5

  • 33.6 inline

    inline

    inline 3.6.1 void Foo(int x, int y);inline void Foo(int x, int y) {}

  • 33.6

    3.6.2

  • 3

  • 3

    1strcmp

    2atoffloat

  • 3

    1strcmp

    2atoffloat double

  • 312007/11/20 15:34

    2

    ******************************