3 1706
On 30 Nov 2005 11:24:06 -0800, in comp.lang.c , "andy_dufre sne"
<ak*******@gmai l.com> wrote: have posted the question here:
http://groups.google.com/group/progr...b58c897f890930
Then please post it here, too, assuming its topical.
--
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 =----
can't replace to other site, just here only, post you question at here
better.
"andy_dufre sne" <ak*******@gmai l.com>
??????:11****** *************** @g47g2000cwa.go oglegroups.com. .. have posted the question here:
http://groups.google.com/group/progr...d/75b58c897f89
0930
sorry abt that.
here's the question:
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)?? 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 (subtraction
between two
pointers to members of the same array) is not pointer arithmetic and we
need
to scale it??
eg problem:
Orig string - char *s;
Ptrs, char *start = s, *end = s;
int length;
while(!isspace( *end))
end++;
length = end - start;
is this mentioned somewhere in the c std?? if so could someone pt me in
the right direction.
Thanks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Daniel Rudy |
last post by:
Hello,
On a x86 machine, what is the format of a pointer in C? I know for a
fact that the x86 p-mode uses a /selector:offset/ notation where the
selector is defined in either the GDT or LDT. Does that carry over into
the pointer, or does Unix use the flat memory model?
--
Daniel Rudy
|
by: Ken Turkowski |
last post by:
The construct
(void*)(((long)ptr + 3) & ~3)
worked well until now to enforce alignment of the pointer to long
boundaries. However, now VC++ warns about it, undoubtedly to help things
work on 64 bit machines, i.e. with 64 bit pointers.
In the early days of C, where there were problems with the size of int
being 16 or 32 bits, the response was that an int was guaranteed to hold
a pointer (yes, there were 64Kb address spaces at one time!)....
|
by: andy_dufresne |
last post by:
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)?? i believe it
would give the correct length, because the compiler is responsible for
scaling the...
|
by: santosh |
last post by:
In following code
char str = "asdf" ;
str = 's' ;
is possible.
But char *str = "asdf" ;
str = 's' ;
is an run-time error.
What i understand is *str = "asdf" is stored in Read-only-Memory. Where
|
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...
| |
by: Spiro Trikaliotis |
last post by:
Hello,
I have a question regarding subtracting a pointer from another one.
Assume I have two pointers p1 and p2, which both point to a memory area
obtained with malloc(). Assume p1 = p2 + some value c.
Now, I want to obtain the difference between the two, that is, the value
c. Which type must I use for c?
I searched around and did not find a definitive answer (not even in the
|
by: MotoK |
last post by:
Hi Experts,
I've just joined this group and want to know something:
Is there something similar to smart pointers in C or something to
prevent memory leakages in C programs.
Regards
MotoK
|
by: kyagrd |
last post by:
<code>
#include <iostream>
int main(void)
{
using namespace std;
int p;
int* p1 = p;
int* p11 = p + 2;
|
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:
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |