Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: difference between casting and atol,atoi functions

Reply
Thread Tools

Re: difference between casting and atol,atoi functions

 
 
infobahn
Guest
Posts: n/a
 
      02-15-2005
Janice wrote:
>
> unsigned char buf[255];
> signed long* x;
> signed long y;
> buf[0]=255;
> buf[1]=255;
> buf[2]=255;
> buf[3]=255;
> //statment 1
> x=(signed long*)buf;
> //statement 2
> y=atol(buf,4);
>
> What is the difference between statement 1 and 2?
> Thanx


The difference is a subtle one. The first statement is stupid because
it invokes undefined behaviour, whereas the second one is stupid
because it invokes undefined behaviour.
 
Reply With Quote
 
 
 
 
Randy Howard
Guest
Posts: n/a
 
      02-15-2005
In article <(E-Mail Removed)>,
http://www.velocityreviews.com/forums/(E-Mail Removed) says...
>
> The difference is a subtle one. The first statement is stupid because
> it invokes undefined behaviour, whereas the second one is stupid
> because it invokes undefined behaviour.


This would make a much better .sig candidate with the author's proper
name attached.

--
Randy Howard (2reply remove FOOBAR)
"Making it hard to do stupid things often makes it hard
to do smart ones too." -- Andrew Koenig
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between typecasting and casting Nishu C Programming 6 02-17-2007 12:06 PM
difference between toString() and type casting a n Object to String narsing Java 2 10-23-2006 07:24 AM
Difference between casting by as and normal cast =?Utf-8?B?UmFlZCBTYXdhbGhh?= ASP .Net 2 08-15-2005 04:00 PM
Difference between bin and obj directories and difference between project references and dll references jakk ASP .Net 4 03-22-2005 09:23 PM
Re: difference between casting and atol,atoi functions Olaf C Programming 0 02-15-2005 06:56 AM



Advertisments