answersLogoWhite

0


Best Answer
Answer

quite a low level view required ......everything stored in memmory is in form of bits (i.e. a sequence of 01). It dependes upon how you are going to read a value. Same sequence of bits can give you different values..try printing x=10; printf("%c %d",x,x);


AnswerThis is the same problem as getting the previous value of a regular variable. For example:
int x = 5;
x = 2;

How do you get the previous value of x (5)? If you didn't store the value in another variable before overwriting it with 2, then you can't. The old value is overwritten and cannot be recovered. In a union, it's possible that you might overwrite only part of a previous value if you store a value to a smaller data type. For example:
union { long a; short b; } c;
c.a = 5;
c.b = 2;

It's possible that you can recover some of the old data of c.a, but for most practical purposes that value would be garbage (and it really depends on the exact alignment of the variables and byte endianness).

User Avatar

Wiki User

โˆ™ 2009-10-13 07:59:39
This answer is:
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
User Avatar

Add your answer:

Earn +20 pts
Q: If the variables in a union use the same address so the previous value will be lost if a new value is entered how do you get the previous value?
Write your answer...
Submit
Related questions

What was the date when Louisiana entered the union?

Lousiana entered the union on 1812


How memory space is occupied by union variables in C programming language?

A union is an aggregate of members that share the same memory address. The size of a union is determined by the largest member.


What states entered the union?

All of the fifty (50) states have entered the union.


Can Minnesota entered the union as a state?

Yes. It entered the Union as a state in 1858.


What day was Georgia entered into the union?

January 2, 1788 Georgia entered the Union.


When Missouri entered the Union as a free state California entered the Union as a free state?

Under the provisions of the Missouri Compromise, Maine was the state that entered the Union with Missouri.


Which was the first state entered the union?

Which state entered the union in 1916 as an officially bilingual state?


Why the colony of Massachusetts entered the union?

The entered union of Massachusetts is Feb. 6, 1788(6th)


What state entered the Union as a free state as a result of the Missouri Compromise?

the state that entered the Union as a free state was Maine and the state that entered the Union as a slave state was Missouri.


Which state entered the union in 1916 as an officially bilingual state?

None of the US states entered the Union in 1916. New Mexico entered the Union as an officially bilingual state in 1912.


What states entered the union between 1851 and 1876?

Which states entered the Union between 1851 and 1876


What states entered the union in 1959?

There were two states that entered into the Union in the year 1959. These states were Alaska and Hawaii and the last to enter the Union.


Who Minnesota entered the union as a state?

The Minnesota Territory leaders petitioned the US Congress in 1858 to be entered into the Union as a state.


When was South Dakota entered in the Union?

South Dakota entered the Union and became a US state on November 2, 1889.


Did Pennsylvania entered the union?

Pennsylvania was second state to enter union and that date was Dec. 12, 1787. It was settled in 1682 but no state entered union before Union was formed after Constitution was written.


When did Florida entered the union?

1845


When was Illinois entered into union?

1818


Which state entered the union as a slave state in 1819?

The only state that entered the Union in 1819 was Alabama, on Dec. 14, 1819.


What number did the state Utah become a state?

Utah entered the union on January 1, 1896, and is the 45th state entered in the union.


Washington was what state in the union?

Washington was the 42nd state that entered into the union.


How many states entered the union during Richard Nixon's presidency?

No states entered the Union during the Presidency of Richard M. Nixon.


What are the dates and states that entered the Union while John Adams was President?

there are no states that entered the union while President John Adams was in office.


When did Florida state entered the union?

Florida state entered the Union on March 3, 1845. Florida was the 27th state to join the Union. Florida is the 22nd largest state in the country.


When was Florida admitted into the Union?

Florida entered the Union on March 3, 1845.


When did Idaho join the union?

Idaho entered the union July 3, 1890