Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #14360 > unrolled thread
| Started by | curixinfotech <curixinfotech.54dl3z@no-mx.forums.yourdomain.com.au> |
|---|---|
| First post | 2011-12-07 07:22 -0500 |
| Last post | 2011-12-19 02:48 -0800 |
| Articles | 6 on this page of 86 — 32 participants |
Back to article view | Back to comp.lang.c
Why C has Pointers. curixinfotech <curixinfotech.54dl3z@no-mx.forums.yourdomain.com.au> - 2011-12-07 07:22 -0500
Re: Why C has Pointers. Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-12-07 04:35 -0800
Re: Why C has Pointers. Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-07 07:58 -0500
Re: Why C has Pointers. Mike Manilone <zhtx10@gmail.com> - 2011-12-07 13:15 +0000
Re: Why C has Pointers. Bill Reid <hormelfree@gmail.com> - 2011-12-08 06:29 -0800
Re: Why C has Pointers. Vincenzo Mercuri <vincenzo.mercuri@hotmail.it> - 2011-12-07 14:50 +0100
Re: Why C has Pointers. Keith Thompson <kst-u@mib.org> - 2011-12-07 11:01 -0800
Re: Why C has Pointers. Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> - 2011-12-07 20:49 +0100
Re: Why C has Pointers. Brian <nospam@nospam.com> - 2011-12-07 20:00 +0000
Re: Why C has Pointers. James Kuyper <jameskuyper@verizon.net> - 2011-12-07 15:30 -0500
Re: Why C has Pointers. 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-07 12:43 -0800
Re: Why C has Pointers. Keith Thompson <kst-u@mib.org> - 2011-12-07 13:09 -0800
Re: Why C has Pointers. Vincenzo Mercuri <vincenzo.mercuri@hotmail.it> - 2011-12-08 19:39 +0100
Re: Why C has Pointers. James Kuyper <jameskuyper@verizon.net> - 2011-12-08 14:16 -0500
Re: Why C has Pointers. Vincenzo Mercuri <vincenzo.mercuri@hotmail.it> - 2011-12-08 20:23 +0100
Re: Why C has Pointers. Kaz Kylheku <kaz@kylheku.com> - 2011-12-07 20:48 +0000
Re: Why C has Pointers. Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> - 2011-12-07 22:07 +0100
Re: Why C has Pointers. Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-12-10 07:34 +0000
Re: Why C has Pointers. August Karlstrom <fusionfile@gmail.com> - 2011-12-07 16:16 +0100
Re: Why C has Pointers. Borax Man <rotflol2@hotmail.com> - 2011-12-08 18:32 +1100
Re: Why C has Pointers. Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-12-08 00:20 -0800
Re: Why C has Pointers. André Gillibert <MetaEntropy.removeThis@gmail.com> - 2011-12-08 13:44 +0100
Re: Why C has Pointers. Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-12-09 05:04 -0800
Re: Why C has Pointers. gazelle@shell.xmission.com (Kenny McCormack) - 2011-12-09 14:59 +0000
Re: Why C has Pointers. Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-12-09 20:19 -0800
Re: Why C has Pointers. Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-12-10 07:36 -0800
Re: Why C has Pointers. Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-12-08 00:12 -0800
Re: Why C has Pointers. Cong Wang <xiyou.wangcong@gmail.com> - 2011-12-15 07:26 +0000
Re: Why C has Pointers. 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-17 08:51 -0800
Re: Why C has Pointers. Barry Schwarz <schwarzb@dqel.com> - 2011-12-17 10:10 -0800
Re: Why C has Pointers. ralph <nt_consulting64@yahoo.net> - 2011-12-17 14:28 -0600
Re: Why C has Pointers. ralph <nt_consulting64@yahoo.net> - 2011-12-17 15:00 -0600
Re: Why C has Pointers. Keith Thompson <kst-u@mib.org> - 2011-12-17 13:55 -0800
Re: Why C has Pointers. ralph <nt_consulting64@yahoo.net> - 2011-12-17 18:27 -0600
Re: Why C has Pointers. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-18 01:26 +0000
Re: Why C has Pointers. ralph <nt_consulting64@yahoo.net> - 2011-12-17 22:34 -0600
Re: Why C has Pointers. "Philip Lantz" <prl@canterey.us> - 2011-12-17 23:48 -0800
Re: Why C has Pointers. superpollo <superpollo@tznvy.pbz> - 2011-12-18 11:06 +0100
Re: Why C has Pointers. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-18 13:44 +0000
Re: Why C has Pointers. pete <pfiland@mindspring.com> - 2011-12-18 11:05 -0500
Re: Why C has Pointers. James Kuyper <jameskuyper@verizon.net> - 2011-12-18 11:50 -0500
Re: Why C has Pointers. Keith Thompson <kst-u@mib.org> - 2011-12-18 13:10 -0800
Re: Why C has Pointers. ralph <nt_consulting64@yahoo.net> - 2011-12-27 16:03 -0600
Re: Why C has Pointers. Barry Schwarz <schwarzb@dqel.com> - 2011-12-27 14:40 -0800
Re: Why C has Pointers. Keith Thompson <kst-u@mib.org> - 2011-12-27 15:08 -0800
Re: Why C has Pointers. ralph <nt_consulting64@yahoo.net> - 2011-12-27 20:09 -0600
Re: Why C has Pointers. Keith Thompson <kst-u@mib.org> - 2011-12-27 23:00 -0800
Re: Why C has Pointers. Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-12-28 02:53 -0800
Re: Why C has Pointers. James Kuyper <jameskuyper@verizon.net> - 2011-12-28 08:39 -0500
Re: Why C has Pointers. James Kuyper <jameskuyper@verizon.net> - 2011-12-27 18:14 -0500
Re: Why C has Pointers. Keith Thompson <kst-u@mib.org> - 2011-12-27 15:36 -0800
Re: Why C has Pointers. James Kuyper <jameskuyper@verizon.net> - 2011-12-27 18:53 -0500
Re: Why C has Pointers. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-28 13:20 +0000
Re: Why C has Pointers. John Bode <jfbode1029@gmail.com> - 2011-12-28 08:42 -0800
Re: Why C has Pointers. 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-17 20:36 -0800
Re: Why C has Pointers. Seebs <usenet-nospam@seebs.net> - 2011-12-18 04:56 +0000
Re: Why C has Pointers. 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-17 21:37 -0800
Re: Why C has Pointers. Seebs <usenet-nospam@seebs.net> - 2011-12-18 05:42 +0000
Re: Why C has Pointers. 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-18 08:08 -0800
Re: Why C has Pointers. Robert Wessel <robertwessel2@yahoo.com> - 2011-12-18 10:36 -0600
Re: Why C has Pointers. Seebs <usenet-nospam@seebs.net> - 2011-12-18 18:50 +0000
Re: Why C has Pointers. Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-12-19 02:39 -0800
Re: Why C has Pointers. gordonb.1i27q@burditt.org (Gordon Burditt) - 2011-12-21 22:34 -0600
Re: Why C has Pointers. 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-19 07:56 -0800
Re: Why C has Pointers. John Tsiombikas <nuclear@member.fsf.org> - 2011-12-19 18:38 +0000
Re: Why C has Pointers. 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-19 13:47 -0800
Re: Why C has Pointers. Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-12-28 02:58 -0800
Re: Why C has Pointers. 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-28 03:21 -0800
Re: Why C has Pointers. Keith Thompson <kst-u@mib.org> - 2011-12-18 13:07 -0800
Re: Why C has Pointers. "io_x" <a@b.c.invalid> - 2011-12-19 04:02 +0100
Re: Why C has Pointers. 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-17 15:35 -0800
Re: Why C has Pointers. ralph <nt_consulting64@yahoo.net> - 2011-12-17 18:41 -0600
Re: Why C has Pointers. John Bode <jfbode1029@gmail.com> - 2011-12-19 05:14 -0800
Re: Why C has Pointers. 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-18 09:50 -0800
Re: Why C has Pointers. 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-09 15:48 -0800
Re: Why C has Pointers. Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-10 00:21 -0800
Re: Why C has Pointers. 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-10 01:03 -0800
Re: Why C has Pointers. Keith Thompson <kst-u@mib.org> - 2011-12-17 11:45 -0800
Re: Why C has Pointers. 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-17 15:18 -0800
Re: Why C has Pointers. 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-19 14:10 -0800
Re: Why C has Pointers. 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-20 10:46 -0800
Re: Why C has Pointers. "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2011-12-17 19:15 +0100
Re: Why C has Pointers. "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2011-12-17 19:19 +0100
Re: Why C has Pointers. Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-12-19 02:48 -0800
Re: Why C has Pointers. 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-18 11:05 -0800
Re: Why C has Pointers. Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-12-19 02:48 -0800
Page 5 of 5 — ← Prev page 1 2 3 4 [5]
| From | 88888 Dihedral <dihedral88888@googlemail.com> |
|---|---|
| Date | 2011-12-20 10:46 -0800 |
| Message-ID | <5758089.36.1324406811505.JavaMail.geo-discussion-forums@prez15> |
| In reply to | #14773 |
On Tuesday, December 20, 2011 6:10:24 AM UTC+8, 88888 Dihedral wrote:
> On Sunday, December 18, 2011 3:45:14 AM UTC+8, Keith Thompson wrote:
> > 88888 Dihedral <dihe...@googlemail.com> writes:
> > > On Wednesday, December 7, 2011 8:22:56 PM UTC+8, curixinfotech wrote:
> > >> my Q is on the c language tell me now why c has pointers.
> > >> parshant
> > >
> > > OK, I'll explain how to use a pointer in C without any knowledge in the
> > > hardware or assembly here.
> > > //
> > > int i;
> > > int a[3]={ 1,2,3} ; // an array of 3 integers
> > > int* ptr1; // Note the star should be right after int, not initialize
> >
> > Why should the * be adjacent to "int"? My own preferred style (and, I
> > think, that of most C programmers) is:
> >
> > int *ptr1;
> >
> > The syntax of declarations in C follows (more or less) the syntax of
> > expressions; "declaration follows use". So "int *ptr;" says that *ptr
> > is an int -- from which it follows that ptr is a pointer to an int,
> > i.e., an int*.
> >
> > This layout follows the grammar more closely, and makes an (admittedly
> > unwise) declaration like this:
> >
> > int *pointer, not_a_pointer;
> >
> > easier to understand.
> >
> > But there is a school of thought that prefers to put the * next to the
> > type name. That seems to be the usual convention in C++. That's ok if
> > you avoid declaring multiple variables in one declaration (which you
> > should probably do anyway).
> >
> > Note that the same principle might suggest:
> >
> > int[3] arr;
> >
> > which is of course a syntax error.
> >
> > > int* ptr2; // not initialized
> > >
> > > ptr1=a; // Read this as to make ptr1 to be an alias of a.
> >
> > That's not necessarily a good way to think of it. Since "a" is an array
> > object the expression consisting of its name decays to a pointer to its
> > first element. That pointer value is then stored in ptr1. ptr1 points
> > to the first element of a. To show that it's not a true alias, consider
> > sizeof a vs. sizeof ptr1.
>
> I do not allocate arrays in the auto mode very often in C.
> But for an example, I just have to show the silly array allocated in the
> auto mode.
>
> Normally I allocate a buffer from the heap by malloc.
> Also I wrote functions that could return pointers and have to clean up
> local buffers correctly before exiting the function.
Also there's no need to free arrays on the stack of auto variables.
One just has to clean those buffers from the heap exactly without errors.
[toc] | [prev] | [next] | [standalone]
| From | "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> |
|---|---|
| Date | 2011-12-17 19:15 +0100 |
| Message-ID | <4a470$4eecdc27$5419acc3$29615@cache60.multikabel.net> |
| In reply to | #14360 |
From what I have read and vaguely remember: C was once designed to be a "value language" this can still be seen today as C misses "call by reference" instead pointers need to be used. Java attempted a similar idea but also failed and eventually pointers/references were added to Java. So just like Java the C language designer ultimately came to the conclusion that C needs pointers too ! ;) C# (sharp) attempted something like no pointers as well, ultimately it also needed some kind of pointer... Bye, Skybuck :)
[toc] | [prev] | [next] | [standalone]
| From | "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> |
|---|---|
| Date | 2011-12-17 19:19 +0100 |
| Message-ID | <7ee52$4eecdd4f$5419acc3$29018@cache90.multikabel.net> |
| In reply to | #14658 |
So to completely answer your question. Pointer support is a basic language requirement for any serious language as data is stored in memory cells. Without being able to address those memory cells, data could never be copied from cell to cell, a requirement which most computer programs have. There might be a way around pointers by introducing instructions which read different memory cells, for example one above, one below or above and below the current instruction or data item. How usefull such an instruction set would be remains to be seen, it's probably more an attempt at obfuscate logic then anything that can be taken seriously ;) and also rather limited ;) Might as well use pointers instead. Bye, Skybuck.
[toc] | [prev] | [next] | [standalone]
| From | Nick Keighley <nick_keighley_nospam@hotmail.com> |
|---|---|
| Date | 2011-12-19 02:48 -0800 |
| Message-ID | <8f304bb7-107c-405c-9b1f-e979df98bc5a@n39g2000yqh.googlegroups.com> |
| In reply to | #14659 |
On Dec 17, 6:19 pm, "Skybuck Flying" <Windows7I...@DreamPC2006.com> wrote: > So to completely answer your question. > > Pointer support is a basic language requirement for any serious language as > data is stored in memory cells. nonsense. many "serious" langauges manage without pointers. > Without being able to address those memory cells, data could never be copied > from cell to cell, a requirement which most computer programs have. nonsense. Any lanaguage that supports assignment can copy data from one "cell" to another. No pointers necessary. You are confusing language with implementation in a manner that throws away 50 years of programming experience. Why not just progarm in assembler if you want access to the underlying hardware? > There might be a way around pointers by introducing instructions which read > different memory cells, for example one above, one below or above and below > the current instruction or data item. go and look at a few other programming languages. > How usefull such an instruction set would be remains to be seen, it's > probably more an attempt at obfuscate logic then anything that can be taken > seriously ;) and also rather limited ;) > > Might as well use pointers instead. I don't understand why they got rid of plug boards. Any serious computer needs a plugboard to specify the data paths.
[toc] | [prev] | [next] | [standalone]
| From | 88888 Dihedral <dihedral88888@googlemail.com> |
|---|---|
| Date | 2011-12-18 11:05 -0800 |
| Message-ID | <25087238.983.1324235110668.JavaMail.geo-discussion-forums@yqba2> |
| In reply to | #14360 |
It is simple in the math that the number of bits can represent is more powerful when the number of bits grow with the implementation in the electronics industry. Passing by an address of a fixed number of bits is more efficient than a deep copy proved.
[toc] | [prev] | [next] | [standalone]
| From | Nick Keighley <nick_keighley_nospam@hotmail.com> |
|---|---|
| Date | 2011-12-19 02:48 -0800 |
| Message-ID | <f1fbdf86-6d76-4adc-a260-733477d95f8d@l29g2000yqf.googlegroups.com> |
| In reply to | #14697 |
On Dec 18, 7:05 pm, 88888 Dihedral <dihedral88...@googlemail.com> wrote: > It is simple in the math that the number of bits can represent is more powerful > when the number of bits grow with the implementation in the electronics industry. > > Passing by an address of a fixed number of bits is more efficient than a deep > copy proved. Haiku?
[toc] | [prev] | [standalone]
Page 5 of 5 — ← Prev page 1 2 3 4 [5]
Back to top | Article view | comp.lang.c
csiph-web