
C
C语言基础知识
dxm809
这个作者很懒,什么都没留下…
展开
-
C enum的用法
#include <stdio.h> enum DAY{ MON=1, TUE, WED, THU, FRI, SAT, SUN}; int main(){ enum DAY day; day = WED; printf("%d",day); return 0;}原创 2021-06-05 08:58:31 · 152 阅读 · 0 评论 -
C 从函数返回数组
C 语言不允许返回一个完整的数组作为函数的参数。但是,您可以通过指定不带索引的数组名来返回一个指向数组的指针。int * myFunction(){...}原创 2021-06-05 08:55:40 · 127 阅读 · 0 评论 -
C 传递数组参数
方式 1形式参数是一个指针void myFunction(int *param){...}方式 2形式参数是一个已定义大小的数组:原创 2021-06-05 08:52:59 · 205 阅读 · 0 评论 -
C time.h
#include <stdio.h>#include <string.h>#include <time.h>int main(){ struct tm t; t.tm_sec = 10; t.tm_min = 10; t.tm_hour = 6; t.tm_mday = 25; t.tm_mon = 2; t.tm_year = 89; t.tm_wday = 6; p.原创 2021-06-05 08:47:26 · 150 阅读 · 0 评论 -
C string.h
#include <stdio.h>#include <string.h> int main (){ const char str[] = "http://www.runoob.com"; const char ch = '.'; char *ret; ret = (char*)memchr(str, ch, strlen(str)); printf("|%c| 之后的字符串是 - |%s|\n", ch, ret); ret.原创 2021-06-05 08:29:19 · 381 阅读 · 0 评论 -
C stdlib.h
#include <stdio.h>#include <stdlib.h>#include <string.h> int main(){ float val; char str[20]; strcpy(str, "98993489"); val = atof(str); printf("字符串值 = %s, 浮点值 = %f\n", str, val); strcpy(str, "runoob"); val.原创 2021-06-04 16:09:35 · 330 阅读 · 0 评论 -
C stdio.h
#include <stdio.h>int main(){ FILE *fp; fp = fopen("file.txt", "w"); fprintf(fp, "%s", "这里是 runoob.com"); fclose(fp); return(0);}原创 2021-06-04 15:32:15 · 315 阅读 · 0 评论 -
C stddef.h
下面是头文件 stddef.h 中定义的变量类型:序号 变量 & 描述 1 ptrdiff_t 这是有符号整数类型,它是两个指针相减的结果。 2 size_t 这是无符号整数类型,它是sizeof关键字的结果。 3 wchar_t 这是一个宽字符常量大小的整数类型。 库宏下面是头文件 stddef.h 中定义的宏:序号 宏 & 描述 1 NULL 这个宏是一个空指针常量的值。 2 off..原创 2021-06-04 13:57:52 · 177 阅读 · 0 评论 -
C stdarg.h
#include<stdarg.h>#include<stdio.h>int sum(int, ...);int main(void){ printf("10、20 和 30 的和 = %d\n", sum(3, 10, 20, 30) ); printf("4、20、25 和 30 的和 = %d\n", sum(4, 4, 20, 25, 30) ); return 0;}int sum(int num_args, ...){ .原创 2021-06-04 13:53:56 · 191 阅读 · 0 评论 -
C math.h
下面列出了头文件 math.h 中定义的函数:序号 函数 & 描述 1 double acos(double x) 返回以弧度表示的 x 的反余弦。 2 double asin(double x) 返回以弧度表示的 x 的反正弦。 3 double atan(double x) 返回以弧度表示的 x 的反正切。 4 double atan2(double y, double x) 返回以弧度表示的 y/x 的反正切。y 和 x原创 2021-06-04 13:47:48 · 288 阅读 · 0 评论 -
C locale.h
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <time.h>#include <locale.h>int main(){ time_t currtime; struct tm* timer; char buffer[80]; time(&currtime); timer = localtime(&currtime); .原创 2021-06-04 13:43:44 · 158 阅读 · 0 评论 -
c limits.h
#include <stdio.h>#include <limits.h>int main(){ printf("The number of bits in a byte %d\n", CHAR_BIT); printf("The minimum value of SIGNED CHAR = %d\n", SCHAR_MIN); printf("The maximum value of SIGNED CHAR = %d\n", SCHAR_MAX).原创 2021-06-04 13:31:00 · 126 阅读 · 0 评论 -
c ctype.h
#include <stdio.h>#include <ctype.h>int main(){ int var1 = 'd'; int var2 = '2'; int var3 = '\t'; int var4 = ' '; if (isalnum(var1)) { printf("var1 = |%c| 是字母数字\n", var1); } else { printf.原创 2021-06-04 13:27:00 · 169 阅读 · 0 评论 -
C assert的使用
#include <stdio.h>#include <assert.h>int main(){ int i = 0; assert(i != 0);}原创 2021-06-04 11:24:30 · 106 阅读 · 0 评论