Hi folks,
a simple question for the experts, I guess.
Obviously I am doing something wrong when trying to access an element
of an array declared within a structure:
#include <stdio.h>
#include <stddef.h>
main() {
const int SIZE = 2 ;
struct test {
long type ;
size_t files[SIZE] ;
} ;
struct test example ;
example.type = 100 ;
example.files[0] = 2 ;
printf("type %d - file size %lld:\n", example.type,
example.files[0] ) ;
}
The "intended" output is
type 100 - file size 2:
but I get:
type 100 - file size 12871933952:
(guess I am printing a memory address or something).
What am I doing wrong?
Cheers
Bernd
a simple question for the experts, I guess.
Obviously I am doing something wrong when trying to access an element
of an array declared within a structure:
#include <stdio.h>
#include <stddef.h>
main() {
const int SIZE = 2 ;
struct test {
long type ;
size_t files[SIZE] ;
} ;
struct test example ;
example.type = 100 ;
example.files[0] = 2 ;
printf("type %d - file size %lld:\n", example.type,
example.files[0] ) ;
}
The "intended" output is
type 100 - file size 2:
but I get:
type 100 - file size 12871933952:
(guess I am printing a memory address or something).
What am I doing wrong?
Cheers
Bernd
Comment