⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch15-badmem1.c

📁 linux编程精髓 源代码
💻 C
字号:
/* ch15-badmem1.c --- do bad things with memory */#include <stdio.h>#include <stdlib.h>int main(int argc, char **argv){	char *p;	int i;	p = malloc(30);	strcpy(p, "not 30 bytes");	printf("p = <%s>\n", p);	if (argc == 2) {		if (strcmp(argv[1], "-b") == 0)			p[42] = 'a';	/* touch outside the bounds */		else if (strcmp(argv[1], "-f") == 0) {			free(p);	/* free memory and then use it */			p[0] = 'b';		}	}	/* free(p); */	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -