Mercurial > hg > Applications > Grep
view c/strcpy.c @ 59:af189c727733
fix
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 14 Jul 2015 14:08:36 +0900 |
parents | 6c5b5a6c3489 |
children |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(void){ char *Astring = "test string"; char *Bstring = 0; char *Cstring = Astring; int string_size = strlen((const char*)Astring); Bstring = (char*)malloc(string_size); strcpy(Bstring,(const char*)Astring); puts("[Astring]"); printf("Astring :%s\n",Astring); printf("AstringAddr:%llx\n",(unsigned long long)&Astring); puts(""); //strcpy string puts("[strcpy]"); printf("Bstring :%s\n",Bstring); printf("BstringAddr:%llx\n",(unsigned long long)&Bstring); puts(""); free(Bstring); puts("[Cstring = Astring]"); printf("Cstring :%s\n",Cstring); printf("CstringAddr:%llx\n",(unsigned long long)&Cstring); return(0); }