![]() |
|< 1 2 3 4 >| | ![]() |
34 Einträge, 4 Seiten |
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
struct test1
{
int i;
char c;
char text[512];
}
struct test1 varstruct1;
varstruct1.i = 10;
varstruct1.c = 'a';
strncpy(varstruct.text, "Das ist ein Text", sizeof(varstruct.text));
void function1(const struct test1 * ptr) //Pointer
{
printf("%i\n", ptr->i);
}
function1(&varstruct1);
typedef struct test2
{
int i;
char c;
char text[512];
} Test2, *PTest2;
Test2 varstruct2;
void function2(const PTest2 ptr) //Pointer
{
printf("%s\n", ptr->text);
}
function(&varstruct2);
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
struct test3
{
int i;
char c;
char text[512];
test2() { *text = 0; i = 0; c = 0; } // konstructor
void print() { printf("%i, %s, %s\n", i, &c, text); }
}
test3 varstruct3;
varstruct.print();
varstruct.i = 10;
varstruct.print();
void function3(const test3 * ptr) // pointer
{
test3->print();
}
void funbction3(const test3 & ref) // referenz
{
ref.print();
}
1 2 3 4 5 6
my $struct = { a => 20, b => 30, c => 40, }; print $struct->{a};
![]() |
|< 1 2 3 4 >| | ![]() |
34 Einträge, 4 Seiten |