cfcn_ex.c
Upload User: qdkongtiao
Upload Date: 2022-06-29
Package Size: 356k
Code Size: 0k
Category:

source in ebook

Development Platform:

Visual C++

  1. const char *str = "hello";
  2. void *malloc(int);
  3. char *strcpy(char *, const char *);
  4. int printf(const char *, ...);
  5. int exit(int);
  6. int strlen(const char *);
  7. int main()
  8. {   /* C language program */
  9.     /* allocate space to hold a copy of str */
  10.     char* s = malloc(strlen(str)+1); 
  11.     strcpy(s, str);           /* copy s to str */
  12.     printf("%s, worldn", s); /* print s followed by ", worldn" */
  13.     exit(0);              /* exit program and return 0 to the OS */
  14. }