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?
- What is *(uint32_t*)?
- Why should we typedef a struct so often in C?
- What is a string of hexadecimal digits?
- What is the difference between ++i and i++?
- Stack smashing detected
- Stack smashing detected
- How do I determine the size of my array in C?
- What is the difference between C and embedded C?
- Difference between malloc and calloc?
- segmentation fault : 11
- What are .a and .so files?
- So what does “return 0” actually mean?
- warning: assignment makes integer from pointer without a cast
- How to print the array?
- How to solve the error: assignment to expression with array type
- segmentation fault : 11
- Why use bzero over memset?
- What does “1e” mean?
- how to use uint64_t in C [duplicate]
- How do I solve the following errors: “Undefined reference to WinMain”, “[Error] Id returned 1 exit status”?
- Warning comparison between pointer and integer
- what is the meaning of == sign?
- ARM Assembler – How do I use CMP, BLT and BGT?
- Invalid read of size 8 – Valgrind + C
- warning: incompatible implicit declaration of built-in function ‘xyz’
- strcpy vs strdup
- double free or corruption (fasttop)
- Warning comparison between pointer and integer in C language
- error: expected declaration or statement at end of input in c
- Why do I get clang: error: linker command failed with exit code 1?
- Difference between scanf() and fgets()
- Return char[]/string from a function [duplicate]
- Difference between char* and const char*?
- Output single character in C
- Converting a C program to MIPS
- C: linker command failed with exit code 1
- What’s the equivalent of new/delete of C++ in C?
- sizeof float (3.0) vs (3.0f)
- How to trigger SIGUSR1 and SIGUSR2?
- Array definition – Expression must have a constant value
- Constant pointer vs Pointer to constant
- Variable warning set but not used
- Expected declaration specifier error in function
- strcmp not working
- How to printf a memory address in C
- Data argument not used by format strings in C
- How to print an unsigned char in C?
- How does one represent the empty char?
- Read and write to binary files in C?
- Removing trailing newline character from fgets() input
- What does “request for member ‘*******’ in something not a structure or union” mean?
- What does “request for member ‘*******’ in something not a structure or union” mean?
- “Multiple definition”, “first defined here” errors
- malloc(): memory corruption
- Is there an alternative sleep function in C to milliseconds?
- how use EOF stdin in C
- How does the strtok function in C work? [duplicate]
- Reaching EOF with fgets
- The difference between char * and char[] [duplicate]
- How to clear input buffer in C?
- Compiler warning – suggest parentheses around assignment used as truth value
- error: `itoa` was not declared in this scope