cfcn_ex.c

来自「C++ Primer中文第四版所有配套实例」· C语言 代码 · 共 18 行

C
18
字号
const char *str = "hello";

void *malloc(int);
char *strcpy(char *, const char *);
int printf(const char *, ...);
int exit(int);
int strlen(const char *);

int main()
{   /* C language program */
    /* allocate space to hold a copy of str */
    char* s = malloc(strlen(str)+1); 
    strcpy(s, str);           /* copy s to str */
    printf("%s, world\n", s); /* print s followed by ", world\n" */
    exit(0);              /* exit program and return 0 to the OS */
}

⌨️ 快捷键说明

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