Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect Overflow

Status
Not open for further replies.

selimsl

Programmer
Aug 15, 2005
62
TR
Hi!

Following code convert ascii desimal data to desimal data
Code:
char ascii_array[10]="65535";
unsigned short int datax;			
sscanf(ascii_array,"%u",&datax);
result is: datax->65535
-----------------------------------------
Code:
char ascii_array[10]="65536";
unsigned short int datax;			
sscanf(ascii_array,"%u",&datax);
result is: datax->0

Because datax is unsigned short int and an overflow occurs.
Is there any method to detect whether an overflow occurs or not?

Thanks in advice...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top