Created
October 31, 2011 18:46
-
-
Save sunnyone/1328426 to your computer and use it in GitHub Desktop.
small strlen test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <string.h> | |
| #include <stdlib.h> | |
| void | |
| print_length(char *s) | |
| { | |
| size_t len = strlen(s); | |
| printf("Unhappy?: %ld\n", len); | |
| } | |
| int | |
| main(void) | |
| { | |
| char *base = "Unhappy, world! Unhappy, world!"; | |
| char *dest; | |
| dest = malloc(100); | |
| strcpy(dest,base); | |
| print_length(dest); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment