1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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;
}
|