473,836 Members | 1,434 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why pointers??

Why use pointers at all??

Sep 21 '06
62 5055
"Tom St Denis" <to********@gma il.comwrites:
Richard Heathfield wrote:
>So I thought I'd try a different approach. "Okay, if you don't see a need
for them, great! Do whatever you do, without them." At some point, such an
approach will lead to a brick wall, with a door in it labelled "Pointers"
that swings invitingly ajar.

You talk funny.
No, he writes amusingly.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Sep 21 '06 #21
Frederick Gotham said:
Richard Heathfield posted:
>So either gcc is wrong, or Mr Gotham is wrong. I'll give you two guesses.

#include <stdio.h>
Good guess, and well corrected.

You still have another outstanding error that needs correcting - an apology
to Keith Thompson. Don't leave it too long.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Sep 21 '06 #22
Tom St Denis wrote:
Richard Heathfield wrote:
>So I thought I'd try a different approach. "Okay, if you don't see a need
for them, great! Do whatever you do, without them." At some point, such an
approach will lead to a brick wall, with a door in it labelled "Pointers"
that swings invitingly ajar.

You talk funny.
Better than speaking poorly.
Sep 21 '06 #23
On 21 Sep 2006 06:20:50 -0700, in comp.lang.c , "onkar"
<on*******@gmai l.comwrote:
>Why use pointers at all??
How else would you point to things?

(its a homework question, or else a stupid one, its like saying "why
use sausages at all?". )
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Sep 21 '06 #24
onkar wrote:
>
Why use pointers at all??
To point at objects.

--
Some informative links:
news:news.annou nce.newusers
http://www.geocities.com/nnqweb/
http://www.catb.org/~esr/faqs/smart-questions.html
http://www.caliburn.nl/topposting.html
http://www.netmeister.org/news/learn2quote.html

--
Posted via a free Usenet account from http://www.teranews.com

Sep 21 '06 #25
Ancient_Hacker wrote:
onkar wrote:
>Why use pointers at all??

Well, in C, it's hard to impossible to do certain things without
resorting to pointers.

If you can get by with arrays and structs and arrays of structs,
then go ahead.
array references are automatically converted to pointers in most
cases. Especially when passing an array as a function parameter.
So you can to all practical purposes eliminate the use of arrays
also. Now you need to name each component of your original array,
and dispense with indices. What fun.

--
Some informative links:
news:news.annou nce.newusers
http://www.geocities.com/nnqweb/
http://www.catb.org/~esr/faqs/smart-questions.html
http://www.caliburn.nl/topposting.html
http://www.netmeister.org/news/learn2quote.html

--
Posted via a free Usenet account from http://www.teranews.com

Sep 21 '06 #26
August Karlstrom wrote:
>
.... snip ...
>
Raw pointers must be used with great care. With them we can for
instance write a function that returns a pointer to the stack:

int *f(void)
{
int t;

return &t;
}

This is not possible in a language with (only) restricted pointers.
And this is totally useless, since any dereference of the return
value of f results in undefined behaviour. All you can do with it
is compare it for equality with some other int pointer, and the
result should be false. With one possible exception.

int *p1, *p2;

p1 = f();
p2 = f();
if (p1 == p2) puts("possible, but useless");
puts("One example of undefined behaviour");
return 0;

--
Some informative links:
news:news.annou nce.newusers
http://www.geocities.com/nnqweb/
http://www.catb.org/~esr/faqs/smart-questions.html
http://www.caliburn.nl/topposting.html
http://www.netmeister.org/news/learn2quote.html

--
Posted via a free Usenet account from http://www.teranews.com

Sep 21 '06 #27
CBFalconer wrote:
August Karlstrom wrote:

int *f(void)
{
int t;
return &t;
}

And this is totally useless, since any dereference of the return
value of f results in undefined behaviour. All you can do with it
is compare it for equality with some other int pointer, and the
result should be false.
Actually the return value is indeterminate:

6.2.4#2
The value of a pointer becomes indeterminate when
the object it points to reaches the end of its lifetime.

so you could be evaluating a trap representation (ie. UB) by
assigning it to a variable. I'm not sure whether:

f();

causes UB or not.

Sep 21 '06 #28
Richard Heathfield posted:
You still have another outstanding error that needs correcting - an
apology to Keith Thompson. Don't leave it too long.
I can think for myself, thank you.

I do not deny the original allegation (in fact, I hereby confirm it). I
condemn the dragging up of old, forgotten business when the only gain is to
cause conflict and breed animosity.

Whether offence was intended or not, or whether offence was taken, is of
little consequence to me at this stage -- in fact, I've long forgotten the
argument.

In "real life", I might be inclined to settle little matters such as these
with dialogue, and other times I might decide that it's better to let
things silently blow over. Different resolutions suit different conflicts.
In internet discussions such as these however, I get a bit lost for words;
I might write a paragraph or two, but then realise that I'm assuming my
audience is of the same culture as mine, and so forth -- at which point I
resign myself to the fact that I simply don't understand how he or she
thinks. Without face-to-face contact, it can be hard to read the other
person.

I don't understand why such offense was taken to the word, "fascist". My
intent to was to poke at you, Kieth, expressing my condemnation of your
attitude to "char unsigned". The intent was to stir you, not to downright
offend you with offensive labels (e.g. such as "son of a bitch",
"shithead", etc.). If you were highly offended by this, then you must
understand that I am at a loss to understand why.

Finally: This is an old, forgotten topic. If I were to call everyone up on
everything bad they'd ever done to me, I wouldn't have any friends. Nor
family come to think of it.

--

Frederick Gotham
Sep 21 '06 #29
Frederick Gotham said:
I don't understand why such offense was taken to the word, "fascist".
Then it's time for you to study a little history, bonehead.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Sep 21 '06 #30

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

Similar topics

27
3417
by: Susan Baker | last post by:
Hi, I'm just reading about smart pointers.. I have some existing C code that I would like to provide wrapper classes for. Specifically, I would like to provide wrappers for two stucts defined as ff: typedef struct { float *data ; int count ;
3
3459
by: ozbear | last post by:
This is probably an obvious question. I know that pointer comparisons are only defined if the two pointers point somewhere "into" the storage allocated to the same object, or if they are NULL, or one-past the end of the object as long as it isn't dereferenced. I use "object" in the standard 'C' sense. Is there some special dispensation given to comparing two pointers
9
5070
by: Mikhail Teterin | last post by:
Hello! I'd like to have a variable of a pointer-to-function type. The two possible values are of type (*)(FILE *) and (*)(void *). For example: getter = straight ? fgetc : gzgetc; nextchar = getter(file); What type should I give to `getter' so that the compiler does not issue
12
4099
by: Lance | last post by:
VB.NET (v2003) does not support pointers, right? Assuming that this is true, are there any plans to support pointers in the future? Forgive my ignorance, but if C# supports pointers and C# and VB.NET get compiled into the same code, then I don't understand why VB.NET can't support pointers Thanks for any info Lance
14
2845
by: Alf P. Steinbach | last post by:
Not yet perfect, but: http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01.pdf http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01_examples.zip To access the table of contents, use the "Bookmarks" tab in Adobe Acrobat. Comments, corrections, praise, nits, etc., are still welcome!
92
5145
by: Jim Langston | last post by:
Someone made the statement in a newsgroup that most C++ programmers use smart pointers. His actual phrase was "most of us" but I really don't think that most C++ programmers use smart pointers, but I just don't know. I don't like them because I don't trust them. I use new and delete on pure pointers instead. Do you use smart pointers?
4
3519
by: Josefo | last post by:
Hello, is someone so kind to tell me why I am getting the following errors ? vector_static_function.c:20: error: expected constructor, destructor, or type conversion before '.' token vector_static_function.c:21: error: expected constructor, destructor, or type conversion before '.' token
25
13068
by: J Caesar | last post by:
In C you can compare two pointers, p<q, as long as they come from the same array or the same malloc()ated block. Otherwise you can't. What I'd like to do is write a function int comparable(void *p, void *q) that will take any two pointers and decide whether they can be compared or not. I really can't think how to do this - any suggestions?
54
12039
by: Boris | last post by:
I had a 3 hours meeting today with some fellow programmers that are partly not convinced about using smart pointers in C++. Their main concern is a possible performance impact. I've been explaining the advantages of smart pointers endlessly (which are currently used in all our C++ software; we use the Boost smart pointers) as I'm seriously concerned that there is a shift to raw pointers. We are not developing system software but rather...
2
2990
by: StevenChiasson | last post by:
For the record, not a student, just someone attempting to learn C++. Anyway, the problem I'm having right now is the member function detAddress, of object controller. This is more or less, your standard dynamic address book program. Adding, and listing work just fine. However, deleting, editing and viewing relies on member function retAddress. This function returns an array of pointers that are pointing to created objects. In action, all it...
0
9665
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
10834
Oralloy
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...
0
10541
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
10584
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
10248
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...
1
7782
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
5645
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
4446
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
3
3108
bsmnconsultancy
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...

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.