473,791 Members | 3,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1306
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
1331
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 browser. My problem usually occurs when i need to go back to that post. The search feature on the discussion forum (web page) never returns the post that i earlier posted How can i quickly find my posts through either a search or another tool i.e. i...
6
4570
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
1649
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, 213, 7, 123, 29, -31}; // Find the first element equal to 7 in the array: int* ptr = find(&a, &a, 7);
5
1148
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 CalSelectedDate As Date = Now() Public Property CalSelDate() As Date Get Return CalSelectedDate
26
6720
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 already defined as such. I got the idea that ptrdiff_t had to be the same size as size_t from Plauger's "The Standard C Library," where he states "... It is always the signed type that has the same number of bits as the4 unsigned type chosen for...
1
2255
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 headers, and one function took too many arguments, but I got it to get the same output as the author had. However two projects with istream_iterators failed to compile. I am enclosing the code (it is possible some ot the headers are uneccasary)...
10
3503
by: kyagrd | last post by:
<code> #include <iostream> int main(void) { using namespace std; int p; int* p1 = p; int* p11 = p + 2;
6
14025
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 include any STL files, like list in this example. Please help me. c++ code:
0
9517
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10207
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10156
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9997
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9030
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5435
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.