473,396 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

question posted on another forum (ptrdiff_t)

could someone point me in the right direction regarding this question??

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

thanks.

Nov 30 '05 #1
2 1288
On 30 Nov 2005 11:22:45 -0800, in comp.lang.c , ak*******@gmail.com
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 =----
Nov 30 '05 #2
On 2005-11-30 14:22:45 -0500, ak*******@gmail.com 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.

ak*******@gmail.com 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
cl*******@gmail.com

Nov 30 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: dave | last post by:
I know this is not a .net problem however it is associated with the discussion forum used to host the managed discussions. I can post a question/problem without and difficulty through the web...
6
by: PengYu.UT | last post by:
I'm wondering when I should use ptrdiff_t and size_t instead of int and unsigned int or long and unsigned long? Is there any guideline I should follow? Peng
2
by: alberto | last post by:
I am learning STL with the book STL Tutorial and Reference guide (1 edition), the following example don't run : int main() { // Initialize array a with 10 integers: int a = {12, 3, 25, 7, 11,...
5
by: ajaymehra | last post by:
Hi all, I have a class file called Properties.vb in which I define a publi property as follows ----------------------------------------------------------- Public Class Properties Private...
26
by: robertwessel2 | last post by:
In another thread, a poster mentioned the Posix ssize_t definition (signed version of size_t). My initial reaction was to wonder what the point of the Posix definition was when ptrdiff_t was...
1
by: | last post by:
am studying a book called "STL for C++" by Leen Ammeraal. copy right 1997 I am on page 160 of 209 pages and I have to got the output right for all of the author's examples I had to change the...
10
by: kyagrd | last post by:
<code> #include <iostream> int main(void) { using namespace std; int p; int* p1 = p; int* p11 = p + 2;
6
by: jubelbrus | last post by:
I'm getting the following error, and from 40 to 300 similar error when I try to compile on mac os x. I believe that it has something to do with STL, because this error occures when I try to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.