From 755cbd30b5ca574a1680c664584f5aaeae13efa6 Mon Sep 17 00:00:00 2001 From: "zik.saleeba" Date: Thu, 23 Apr 2009 12:08:27 +0000 Subject: [PATCH] Added new char array test git-svn-id: http://picoc.googlecode.com/svn/trunk@266 21eae674-98b7-11dd-bd71-f92a316d2d60 --- tests/21_char_array.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/21_char_array.c diff --git a/tests/21_char_array.c b/tests/21_char_array.c new file mode 100644 index 0000000..4d1d284 --- /dev/null +++ b/tests/21_char_array.c @@ -0,0 +1,24 @@ +char *a = "hello"; + +printf("%s\n", a); + +int c; +c = *a; + +char *b; +for (b = a; *b != 0; b++) + printf("%c: %d\n", *b, *b); + +char destarray[10]; +char *dest; +char *src; + +dest = &destarray[0]; +src = a; +while (*src != 0) + *dest++ = *src++; + +*dest = 0; + +printf("copied string is %s\n", destarray); +