diff options
Diffstat (limited to 'c99.c')
-rw-r--r-- | c99.c | 46 |
1 files changed, 46 insertions, 0 deletions
@@ -0,0 +1,46 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <memory.h> + +struct node +{ + int x; + int y; + int z; + + char name[21]; +}; +typedef struct node node_t; + +void mymemset(void *mem, char c, unsigned int n) +{ + char *p = (char *) mem; + + while (n--) + *p++ = c; +} + +void func(int arr[]) +{ + printf("the size of arr is: %lu\n", sizeof(arr)); + arr[0] = 9; +} + +int main(int argc, char *argv[]) +{ + node_t *p = (node_t *) malloc(sizeof(node_t) + 21); /* c99 */ + strcpy(p->name, "I have a long name"); + + printf("%s", p->name); + + int myarr[] = { 1,2,3,4,5,6,7,8,9,10 }; + func(myarr); + + printf("%d\n", myarr[0]); + + mymemset(p, -1, sizeof(node_t)); + + return 0; +} + |