Mercurial > hg > Applications > Grep
changeset 0:44fcb6c33604
add strcpy test code
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 26 Nov 2013 15:54:53 +0900 |
parents | |
children | 6c5b5a6c3489 |
files | c/strcpy.c |
diffstat | 1 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c/strcpy.c Tue Nov 26 15:54:53 2013 +0900 @@ -0,0 +1,29 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int main(void){ + char *Astring = "test string"; + char *Bstring = 0; + char *Cstring = 0; + + int string_size = strlen((const char*)Astring); + Bstring = (char*)malloc(string_size); + + strcpy(Bstring,(const char*)Astring); + + printf("Astring :%s\n",Astring); + printf("AstringAddr:%llx\n",(unsigned long long)&Astring); + + //strcpy string + printf("Bstring :%s\n",Bstring); + printf("BstringAddr:%llx\n",(unsigned long long)&Bstring); + free(Bstring); + + Cstring = Astring; + printf("Cstring :%s\n",Cstring); + printf("CstringAddr:%llx\n",(unsigned long long)&Cstring); + + return(0); +} +