summaryrefslogtreecommitdiffstats
path: root/c99.c
diff options
context:
space:
mode:
Diffstat (limited to 'c99.c')
-rw-r--r--c99.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/c99.c b/c99.c
new file mode 100644
index 0000000..d9b4357
--- /dev/null
+++ b/c99.c
@@ -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;
+}
+