-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvoid_pointers.c
More file actions
53 lines (29 loc) · 749 Bytes
/
Copy pathvoid_pointers.c
File metadata and controls
53 lines (29 loc) · 749 Bytes
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
/* void_pointers.c */
/* Playing around with void pointers and structs. */
/* This code is released to the public domain. */
/* "Share and enjoy..." ;) */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
typedef struct
{
char name[30];
int intval;
char charval[40];
} data;
/* A data "object". This has a value. */
void makedata(void *val)
{
data *dp = (data*)val ;
printf("%s \n%d \n%s \n", dp->name, dp->intval, dp->charval);
}
int main()
{
data d;
strcpy(d.name, "Just a test");
d.intval = 123;
strcpy(d.charval, "More stuff");
makedata(&d);
return 0;
}