随笔分类 - C\C++
简单PE文件读取
摘要:#include <stdio.h> #include <windows.h> #include <malloc.h> #include <stdlib.h> LPVOID ReadFile(LPSTR szFileName) { FILE *pFile = NULL; DWORD dwFileSi
阅读全文
posted @ 2020-06-11 03:10
ヤ玥夜ゞ
C语言 字符指针数组使用
摘要:#include <iostream> using namespace std; int main() { char* name[] = { "王莉","张绍然","尚迪"}; //[]优先级高于*,所以name是一个数组,数组里每个成员都是一个char* //如果用二维数组,每个数组成员都事先确定
阅读全文
posted @ 2020-06-08 12:11
ヤ玥夜ゞ
C语言 字符串倒序输出
摘要:#include <stdio.h> #include <string.h> void reverse(char* s) { char *p,*q,temp; p = s; q = s + strlen(s) - 1; while(p < q) { temp = *p; *p = *q; *q =
阅读全文
posted @ 2020-06-08 11:05
ヤ玥夜ゞ
C语言 goto实现循环
摘要:#include <stdio.h> int main() { int a = 0; loop: a++; printf("%d\n",a); if(a == 100) goto end; goto loop; end: return 0; }
阅读全文
posted @ 2020-06-07 17:47
ヤ玥夜ゞ
printf 输出字符数组
摘要:#include <stdio.h> int main() { //char s[] = {'h','e','l','l','o','\0'}; char s[] = {"hello"}; //这种方式可以省略结尾的\0 printf("%s\n",s);//利用%s参数,可以省略我们自己写循环,一
阅读全文
posted @ 2020-06-05 14:06
ヤ玥夜ゞ
二维字符数组输出
摘要:#include <stdio.h> int main() { char a[3][5] = {{'m','a','n','g','o'},{'a','p','p','l','e'},{'g','r','a','p','e'}}; for(int i = 0; i < 3; i++) { for(i
阅读全文
posted @ 2020-06-05 14:00
ヤ玥夜ゞ
C语言 文件包含输出hello world
摘要:Demo.h printf("hello "); printf("world"); Demo.cpp #include <stdio.h> #include <string.h> int main() { #include "Demo.h" return 0; }
阅读全文
posted @ 2020-06-04 13:31
ヤ玥夜ゞ
struct 对齐机制定义
摘要:一般来说,结构体变量占据的内存大小是所有成员变量占据内存大小的总和,但有些例外,需要特别注意。 1、结构体变量的首地址能够被其最宽的基本类型成员的大小所整除。 2、结构体每个成员相对于结构体首地址的偏移量,都是成员大小的整数倍。。 3、结构体的总大小为结构体最宽基本类型成员的大小的整数倍。 字节对齐
阅读全文
posted @ 2020-05-19 23:58
ヤ玥夜ゞ
struct 中数组成员在外部无法赋值
摘要:#include <iostream> #include<cstring> int main() { using namespace std; struct computer { char brand[20]; float price; }com1 = { "Dell",5000 }, com2;
阅读全文
posted @ 2020-05-19 22:19
ヤ玥夜ゞ
浙公网安备 33010602011771号