...
Code Block |
---|
char *copy(size_t n, char *str) { size_t i; char *p = malloc(n); for ( i = 0; i < n; ++i ) { p[i] = *str++; } return p; } char *p = copy(20, "hi there"); |
References
- ISO/IEC 9899:-1999 Section 7.17 Common definitions <stddef.h>
...
Code Block |
---|
char *copy(size_t n, char *str) { size_t i; char *p = malloc(n); for ( i = 0; i < n; ++i ) { p[i] = *str++; } return p; } char *p = copy(20, "hi there"); |