زبان : C -برنامه ای که کاربرد یونیون ها را توضیح می دهد
#include
#include
int main ()
{
union test {
int i ;
char ch ;
float y ;
} un;
clrscr();
printf("\n enter an integer number:");
scanf("%d", &un.i) ;
printf(" the value of i is :%d", un.i);
printf("\n enter a character :") ;
un.ch = getche() ;
printf("\n value of ch is:%c", un.ch);
printf("\n enter a float number :");
scanf("%f", &un.y) ;
printf(" the value of y is:%.2f", un.y);
printf("\n the size of union is:%d", sizeof(union test));
getch();
return 0;
}
+ نوشته شده در سه شنبه دهم اردیبهشت ۱۳۸۷ ساعت 10:0 توسط behzad lotfi
|