Mercurial > hg > Members > masakoha > testcode
changeset 2:c1968e54b0da
add strlen.c
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 04 Dec 2013 21:52:26 +0900 |
parents | 6c5b5a6c3489 |
children | cd6ac4ce5c3c |
files | c/strlen.c |
diffstat | 1 files changed, 22 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c/strlen.c Wed Dec 04 21:52:26 2013 +0900 @@ -0,0 +1,22 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +unsigned char *gWord = 0; + +int main(){ + + gWord = "testcode"; + + int w_len = sizeof(gWord); + unsigned char *word = (unsigned char *)malloc(w_len + 1); + + memcpy(word,gWord,w_len + 1); + + printf("%s\n",word); + printf("length:%d\n",w_len); + + free(word); + + return 0; +}