comparison c/strlen.c @ 2:c1968e54b0da

add strlen.c
author Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
date Wed, 04 Dec 2013 21:52:26 +0900
parents
children
comparison
equal deleted inserted replaced
1:6c5b5a6c3489 2:c1968e54b0da
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4
5 unsigned char *gWord = 0;
6
7 int main(){
8
9 gWord = "testcode";
10
11 int w_len = sizeof(gWord);
12 unsigned char *word = (unsigned char *)malloc(w_len + 1);
13
14 memcpy(word,gWord,w_len + 1);
15
16 printf("%s\n",word);
17 printf("length:%d\n",w_len);
18
19 free(word);
20
21 return 0;
22 }