Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > question posted on another forum (ptrdiff_t)

Reply
Thread Tools

question posted on another forum (ptrdiff_t)

 
 
akshayrao@gmail.com
Guest
Posts: n/a
 
      11-30-2005
could someone point me in the right direction regarding this question??

http://groups.google.com/group/progr...b58c897f890930

thanks.

 
Reply With Quote
 
 
 
 
Mark McIntyre
Guest
Posts: n/a
 
      11-30-2005
On 30 Nov 2005 11:22:45 -0800, in comp.lang.c , http://www.velocityreviews.com/forums/(E-Mail Removed)
wrote:

>could someone point me in the right direction regarding this question??
>
>http://groups.google.com/group/progr...b58c897f890930


If you have a question for comp.lang.c. please post it here - its not
likely that many people will find time to follow a link to google.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
 
Reply With Quote
 
 
 
 
Clark S. Cox III
Guest
Posts: n/a
 
      11-30-2005
On 2005-11-30 14:22:45 -0500, (E-Mail Removed) said:
>could someone point me in the right direction regarding this question??
>
>http://groups.google.com/group/progr...b58c897f890930


First,

it seems kind of rude, to me, to post the question elsewhere, and expect
someone reading the message here to follow a link to find the real question.

(E-Mail Removed) said:
> hi,
> i'd a question abt taking the difference between two pointers.
> for eg:
> if you have 2 char pointers pointing to members of an array, you advance one
> till you encounter a space then take the difference between the two,

will give
> the correct length of the string irrespective of whether char is represented
> by 2 bytes (like in unicode)??


Second, by definition, char is always 1 byte; there are no exceptions. (A byte
may be larger than 8-bits, but sizeof(char) is always equal to 1).

Third, if you're using Unicode, then the functions in ctype.h (like
isspace) are
insufficient.

> i believe it would give the correct length, because the compiler is
> responsible for scaling the difference when one advances a pointer to

point to
> the next element like ptr++, or is it that pointer difference is not pointer
> arithmetic and we need to scale it??


I'm not sure what you mean by scaling, but, assuming that all pointers are
valid, and you don't run off the end of an array, etc.:
If you increment the pointer x times, then (end - start) == x.

> eg problem:
> Orig string - char *s;
> Ptrs, char *start = s, *end = s;
> int length;
> while(*end != isspace(*end))


ITYM: while(!isspace((unsigned char)*end))

>* end++;
> length = end - start;
>
> is this mentioned somewhere in the c std?? if so could someone pt me in the
> right direction.
> Thanks.



--
Clark S. Cox, III
(E-Mail Removed)

 
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
Messages not posted to forum Froefel ASP .Net 1 07-20-2007 12:49 AM
[Ruby Forum] Forum digest by email Alexey Verkhovsky Ruby 0 09-22-2004 07:21 PM
Another Presentation Posted to Why Ruby! Curt Hibbs Ruby 0 05-14-2004 03:30 AM



Advertisments