You are failing to access a field of the indexed union array: mydata[0]
is a value of type union data
, and can’t be cast to uint64_t
.
You need to access the proper union member:
printf("%" PRIu64, mydata[0].val);
to select the uint64_t
value. No need for the cast.
Also: Use PRIu64
to portably print 64-bit values, you can’t assume that %llu
is the right format specifier.
Related Posts:
- Correct format specifier for double in printf
- What does “%.*s” mean in printf?
- Why does ENOENT mean “No such file or directory”?
- Undefined reference to pthread_create in Linux
- what is the difference between uint16_t and unsigned short int incase of 64 bit processor?
- Openssl : error “self signed certificate in certificate chain”
- Strings and character with printf
- Bad File Descriptor with Linux Socket write() Bad File Descriptor C
- Write to .txt file?
- printf() formatting for hexadecimal
- What is the LD_PRELOAD trick?
- What is the argument for printf that formats a long?
- connect Error: “No route to host”
- How to printf “unsigned long” in C?
- Is there a printf converter to print in binary format?
- Difference between a Structure and a Union
- The difference between stdout and STDOUT_FILENO
- Does connect() block for TCP socket?
- where does stdio.o live in linux machine?
- Linux equivalent of I_PUSH
- Display value found at given address gdb
- What can cause a “Resource temporarily unavailable” on sock send() command
- How to print a char array in C through printf?
- Efficient way to find task_struct by pid
- valgrind – Address —- is 0 bytes after a block of size 8 alloc’d
- How can one print a size_t variable portably using the printf family?
- Using floats with sprintf() in embedded C
- Printf width specifier to maintain precision of floating-point value
- Which of sprintf/snprintf is more secure?
- Does C have a string type?
- Execution of printf() and Segmentation Fault
- printf format specifiers for uint32_t and size_t
- What is `S_ISREG()`, and what does it do?
- execvp: bad address error
- How do you format an unsigned long long int using printf?
- What primitive data type is time_t? [duplicate]
- GDB no such file or directory
- How big can a 64 bit unsigned integer be?
- The difference between n++ and ++n at the end of a while loop? (ANSI C)
- How many spaces for tab character(\t)?
- Implementing Taylor Series for sine and cosine in C
- Working on code to calculate cosine with factorial sum
- How to use execvp()
- How to use execvp() to execute a command
- How does strtok() split the string into tokens in C?
- warning: implicit declaration of function
- warning: implicit declaration of function
- What is *(uint32_t*)?
- pthread_join() and pthread_exit()
- what is Segmentation fault (core dumped)? [duplicate]
- What causes a segmentation fault (core dump) to occur in C?
- uint8_t vs unsigned char
- How to use symbols of extended ASCII table in C?
- Two questions about basic C programs
- What is the difference between ++i and i++?
- Using boolean values in C
- What does “collect2: error: ld returned 1 exit status” mean?
- How to convert an int to string in C?
- typedef struct vs struct definitions [duplicate]
- How to print in C
- Why should we typedef a struct so often in C?
- What is a string of hexadecimal digits?
- Why should we typedef a struct so often in C?
- What exactly is the difference between “pass by reference” in C and in C++?
- What is the difference between ++i and i++?
- What can be the reasons of connection refused errors?
- What does “collect2: error: ld returned 1 exit status” mean?
- How to convert an int to string in C?
- typedef struct vs struct definitions [duplicate]
- What is newline character — ‘\n’
- What does the question mark character (‘?’) mean?
- Cannot figure out how to use getchar(); in C
- Floating point exception (core dumped)
- makefile:4: *** missing separator. Stop
- Stack smashing detected
- Why am I getting “void value not ignored as it ought to be”?
- Stack smashing detected
- How do I determine the size of my array in C?
- Why am I getting “void value not ignored as it ought to be”?
- Scanf/Printf double variable C
- Pointer Arithmetic
- dereferencing pointer to incomplete type
- 1 = false and 0 = true?
- c stack smashing detected
- How to convert a string to integer in C?
- What is the difference between C and embedded C?
- Get a substring of a char* [duplicate]
- char *array and char array[]
- How do I create an array of strings in C?
- Undefined reference to pthread_create
- What is the behavior of integer division?
- Convert char to int in C and C++
- Get a substring of a char*
- Difference between malloc and calloc?
- What is Bit Masking?
- How do function pointers in C work?
- Expression must be a modifiable L-value
- What causes the Broken Pipe Error?
- segmentation fault : 11
- Awesomium sdk download