随笔分类 - C语言篇
摘要:1 #include 2 /* 3 * 任意十个数,打印出它们中的最大数、最小数 4 * 5 * 测试数据:① 1,-12,20,30,-5,-23,33,125,200,-100 6 ② 0,10,3,1,5,6,-10,90,9,-4 7 ③ 12,13,14,15,10,-10,-11,-12,-9,9 ...
阅读全文
摘要:符号整数类型的范围:整数类型:byte,short,int,longbyte: 8 位 -128 >127short 16位 -32768 >32767int 32位 -2147483648-->2147483647long 64位 -9223372036854775808 --> 92233720
阅读全文
摘要:1 #include 2 #include 3 #include 4 5 /* 6 _Check_return_ _Ret_maybenull_ 7 inline char* __CRTDECL strstr(_In_z_ char* const _String, _In_z_ char const* const _SubString) 8 { 9 ...
阅读全文
摘要:1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 5 int main() 6 { 7 8 /* 9 字符串的赋值: 10 给 char* 类型的字符串赋值,可以直接使用 "=" 号 11 给 char[] 类型的字符串赋值,需要使用 strcpy 函数 12 13 ...
阅读全文
摘要:1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 5 void main() 6 { 7 // tmpfile产生临时文件,关闭文件或者程序关闭,就会自动删除 8 FILE *ptemp = tmpfile();// 创建临时文件,返回文件指针 9 if (ptemp == NULL...
阅读全文
摘要:1/* 增 */ #define _CRT_SECURE_NO_WARNINGS // 关闭安全检查 2 #include 3 #include 4 #include 5 void main() 6 { 7 char path[100] = "C:\\Users\\yakun\\Desktop\\10.txt"; // 文件路径 8 char t...
阅读全文
摘要:1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 5 // 1234567 1234567 % 10 ==> 7 7 * 10 + 6 6 // 1234567 / 10 % 10 ==> 6 7 // 1234567 / 10 / 10 % 10 ==...
阅读全文
摘要:1 文本数据加密 2 3 #define _CRT_SECURE_NO_WARNINGS 4 #include 5 #include 6 7 void run(char *str) 8 { 9 char *p = str; 10 while (*p != '\0') 11 { 12 if (*p == '\r' || *p ==...
阅读全文
摘要:某些时候,我们需要将指针赋值为空指针,以防止野指针。 有人喜欢使用NULL作为空指针常量使用,例如:int* p = NULL;。 也有人直接使用0值作为空指针常量,例如:int* p = 0;。 前者可能觉得:NULL作为空指针常量,名字很形象,可读性较强。 后者可能觉得:NULL并不是C/C++
阅读全文
摘要:=================================================== char *getcwd( char *buffer, int maxlen ); (获取当前目录) // 功 能 : 获得当前工作目录. // 头文件 : #include // 返回值 : 成功返回指向buffer的pointer // 失败返回NULL,...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 7 char *Mystrstr(const char *string, const char *strCharSet) 8 { 9 if (NULL == string) 10 { 11 return...
阅读全文
摘要:利用windows提供的目录操作库和文件操作库,统计指定目录及其子目录中所有.cpp、.c、.h文件的代码量,用来检测自己的编程工作量()。
阅读全文
摘要:1 #include 2 #include 3 4 // 函数声明 5 char *mystrcpy(char *object, char *source); 6 7 void main() 8 { 9 char str[100]; 10 char *p = "Hello,15PB"; 11 12 printf("%s", mystrcpy(s...
阅读全文
摘要:1 #include 2 #include 3 4 // 逆序 5 void rev(int *p, int n) 6 { 7 for (int i = 0; i < n / 2; i++) 8 { 9 int temp = p[i]; 10 p[i] = p[n - 1 - i]; 11 p[n - 1 -...
阅读全文
摘要:1 进制转换 2 #define _CRT_SECURE_NO_WARNINGS 3 #include 4 #include 5 6 // 10 7 // 10 / 2 8 // 5 % 2 ==> 1 9 // 5 / 2 10 // 2 % 2 ==> 0 11 // ...
阅读全文
摘要:1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 #include // sqrt函数 5 6 // 判断一个数是不是素数(质数) 7 //素数: 只能被自己和1整除的数,1,0不是素数 8 9 int isPrime(int num) 10 { 11 if (num == 2) 12 ...
阅读全文
摘要:1 #include 2 #include 3 #define N 13 4 5 6 int main(void) 7 { 8 9 // 定义二维数组 10 int a[N][N] = { 0 }; 11 int i = 0, j = 0; 12 13 for (i = 0; i < N; i++) 14 { 15 ...
阅读全文
摘要:1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 5 int main() 6 { 7 // 定义变量 8 int line; // 菱形总行数 9 int column; // 菱形总列数 10 int i; // 当前行 11 int j...
阅读全文

浙公网安备 33010602011771号