# c_libs **Repository Path**: supertom-spec/c_libs ## Basic Information - **Project Name**: c_libs - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-09-29 - **Last Updated**: 2021-11-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # C libs for conveniently programming ## C keywords - 修饰:auto, const, signed, unsigned, register, volatile, typedef - 类型:char, double, float, int, long, short, enum, struct, union, void, sizeof - 控制:for, while, do, if, else, goto, switch, case, break, continue, default, return - 工程:static, extern ## ANSI ### stdio.h - fopen, fclose, getc, ungetc, putc, fgets, fputs - printf, fprintf, sprintf, scanf, fscanf, sscanf - remove, rename, tmpname ### stdlib.h - abs, rand, srand - malloc, free ### math.h - fabs, floor, ceil - fmod, sqrt, pow, exp, log - sin, cos, atan, atan2 ### ctype.h - toupper, tolower - isalpha, isupper, islower, isdigit, isalnum - ispunct, isspace ### string.h - strlen, strcmp, strncmp, strcpy, strncpy, strcat, strncat - strchr, strrchr, strstr ## Form Eric S. Roberts ### genlib.h - 类型:``bool``, ``string``, ``stream`` - 常量:``UNDEFINED`` 指针 - 内存分配与垃圾回收: - 申请内存:``ptr = (type) GetBlock(nbytes)`` - 释放内存:``FreeBlock(ptr)`` - 为指针申请内存:``p = New(type *)``,相当于 p = (type *)malloc(sizeof(type)) - 为数组申请内存:``p = NewArray(n, type)`` - 错误处理:``void Error(string msg, ...)`` - 控制流:``repeat { ... }``,相当于 while (TRUE) ### simpio.h - 从用户输入获取数据: - ``int i = GetInteger()`` - ``long l = GetLong()`` - ``double f = GetReal()`` - ``string s = GetLine()`` - ``string ReadLine(FILE *infile)`` ### strlib.h - 字符串拼接:``string Concat(string s1, string s2)`` - 字符串指标:``char IthChar(string s, int i)``,相当于 s[i] - 子字符串:``string SubString(string s, int p1, int p2)`` - 单字符转换为串:``string CharToString(char ch)`` - 字符串长度:``int StringLength(string s)`` - 复制字符串:``string CopyString(string s)`` - 判断相等:``bool StringEqual(string s1, string s2)`` - 字符串比较:``int StringCompare(string s1, string s2)``,相当于 strcmp(s1, s2) - 在 text 中查找 ch 字符:``int FindChar(char ch, string text, int start)`` - 在 text 中查找 str 字符串:``int FindString(string str, string text, int start)`` - 转为小写:``string ConvertToLowerCase(string s)`` - 转为大写:``string ConvertToUpperCase(string s)`` - 数字 123 转化为 “123” 字符串表示:``string IntegerToString(int n)`` - 字符串 “123” 转化为 123 数字表示:``int StringToInteger(string s)`` - 浮点数转化为字符串表示:``string RealToString(double d)`` - 字符串表示为浮点数表示:``double StringToReal(string s)`` ### random.h - 初始化:``void Randomize(void)`` - 随机整数:``int RandomInteger(int low, int high)`` - 随机浮点数:``double RandomReal(double low, double high)`` - 按 p 概率返回 TRUE: ``bool RandomChance(double p)``