Skip to content

Instantly share code, notes, and snippets.

@sunnyone
Created October 31, 2011 18:46
Show Gist options
  • Select an option

  • Save sunnyone/1328426 to your computer and use it in GitHub Desktop.

Select an option

Save sunnyone/1328426 to your computer and use it in GitHub Desktop.
small strlen test
#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