AnsweredAssumed Answered

Union in C language problem

Question asked by mohamadi.parisa on Sep 11, 2016
Latest reply on Sep 12, 2016 by AvaTar
Hello
I have written a code like this:
#include <stdio.h>
#include <string.h>
#include "stm32f10x_gpio.h"
#include "stm32f10x_rcc.h"
#include "stm32f10x_usart.h"
#include "stm32f10x_dma.h"
 
union receive{
    unsigned long int Pack;
};
    union receive var1;
 
void check(char data1,char data2){
    unsigned long int buffer[17];
 
buffer[0]=123456;
 
        var1.Pack=buffer[0];
 
    printf("innn%ld",var1.Pack);
}

but it returns 1 instead of 123456 or when I fill it with 654321 value it returns again 1.
what is my mistake?

Outcomes