Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Reference: http://blog.surgut.co.uk/2015/08/go-enjoy-python3.html
- */
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #define LEN 12
- int main(int argc, char *argv[]) {
- char res[LEN+1];
- if (argc != 2) {
- fprintf(stderr, "Usage: %s string\n", argv[0]);
- exit(EXIT_FAILURE);
- }
- /*
- * strncat() onto an empty string behaves the way
- * strncpy() arguably _should_ behave
- */
- res[0] = '\0';
- strncat(res, argv[1], LEN);
- puts(res); /* or printf("%s\n", res) if you prefer */
- return 0; /* optional in C99 or later */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement