2011-09-09 02:41:34 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int numbers[4] = {0};
|
2011-09-09 02:45:09 +00:00
|
|
|
char name[4] = {'a'};
|
2011-09-09 02:41:34 +00:00
|
|
|
|
2012-02-14 03:08:28 +00:00
|
|
|
// first, print them out raw
|
2011-09-09 02:41:34 +00:00
|
|
|
printf("numbers: %d %d %d %d\n",
|
|
|
|
numbers[0], numbers[1],
|
|
|
|
numbers[2], numbers[3]);
|
|
|
|
|
|
|
|
printf("name each: %c %c %c %c\n",
|
|
|
|
name[0], name[1],
|
|
|
|
name[2], name[3]);
|
|
|
|
|
|
|
|
printf("name: %s\n", name);
|
|
|
|
|
2012-02-14 03:08:28 +00:00
|
|
|
// setup the numbers
|
2011-09-09 02:52:39 +00:00
|
|
|
numbers[0] = 1;
|
|
|
|
numbers[1] = 2;
|
|
|
|
numbers[2] = 3;
|
|
|
|
numbers[3] = 4;
|
2011-09-09 02:41:34 +00:00
|
|
|
|
2012-02-14 03:08:28 +00:00
|
|
|
// setup the name
|
2011-09-09 02:41:34 +00:00
|
|
|
name[0] = 'Z';
|
|
|
|
name[1] = 'e';
|
|
|
|
name[2] = 'd';
|
|
|
|
name[3] = '\0';
|
|
|
|
|
2011-09-09 02:52:39 +00:00
|
|
|
printf("%d\n", name[0]);
|
|
|
|
printf("%d\n", name[1]);
|
|
|
|
printf("%d\n", name[2]);
|
|
|
|
printf("%d\n", name[3]);
|
|
|
|
|
2012-02-11 18:26:39 +00:00
|
|
|
printf("name as int=%d\n", (int)*name);
|
2011-09-09 02:52:39 +00:00
|
|
|
|
2012-02-14 03:08:28 +00:00
|
|
|
// then print them out initialized
|
2011-09-09 02:41:34 +00:00
|
|
|
printf("numbers: %d %d %d %d\n",
|
|
|
|
numbers[0], numbers[1],
|
|
|
|
numbers[2], numbers[3]);
|
|
|
|
|
|
|
|
printf("name each: %c %c %c %c\n",
|
|
|
|
name[0], name[1],
|
|
|
|
name[2], name[3]);
|
|
|
|
|
2012-02-14 03:08:28 +00:00
|
|
|
// print the name like a string
|
2011-09-09 02:41:34 +00:00
|
|
|
printf("name: %s\n", name);
|
|
|
|
|
2012-02-14 03:08:28 +00:00
|
|
|
// another way to use name
|
|
|
|
char *another = "Zed";
|
|
|
|
|
|
|
|
printf("another: %s\n", another);
|
|
|
|
|
|
|
|
printf("another each: %c %c %c %c\n",
|
|
|
|
another[0], another[1],
|
|
|
|
another[2], another[3]);
|
|
|
|
|
2011-09-09 02:41:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|