LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-05-2017, 01:10 PM   #61
Peverel
Member
 
Registered: May 2009
Location: Chelmsford, England
Distribution: OpenSuse 12.2 and 13.2, Leap 4.2
Posts: 120

Rep: Reputation: 24

Well, NevemTeve has introduced an interesting point of semantics. In fact argv is a formal parameter of data type char**; at run time it is an actual parameter. that is a variable whose value is a pointer to an array of pointers to character arrays, composed of the strings supplied by the call. This might loosely be described as a data structure, but is not a C struct. In a similar way, one tends to say that, for example, 4.32 is a float, which is actually shorthand for "a constant of data type float".

Incidentally, in K&R C a variable defined as a struct had a value which was a pointer to the structure, mimicking arrays. This was for efficiency, since passing a large structure to a function meant a large overhead in both time and memory at that time. When this was changed to the structure itself, it meant that there were two sets of incompatible compilers, since in one, if a formal parameter was declared as a struct, a pointer was expected, in the other, the object itself.

Last edited by Peverel; 08-05-2017 at 03:01 PM. Reason: mistaken attribution
 
Old 08-06-2017, 12:51 AM   #62
delhiank762
LQ Newbie
 
Registered: Jul 2017
Posts: 2

Rep: Reputation: Disabled
Quote:
Originally Posted by sundialsvcs View Post
A pointer is an integer-type variable whose value is understood to be a memory address. And, by convention, the value zero is NULL (or nil) an indication that the value of the pointer is not significant; that "it doesn't point to anything at all."

I don't consider it to be a "data type" since it is the means to an end. It is not something of particular interest, except that it is the address of something that is interesting to somebody. It is the means of obtaining the address of "the data."

hey my friend,
bro never use that statement henceforth pointer is not a memory its not a debatable topic as it can never be a memory. its juts a variable that points to a memory location. it can have its own memory location can point to a memory location but cannot be a memory location.
hope you know what i am trying to convey. what i can say that you know what exactly pointer is but the term you used is not appropriate
thanks for the reply.
 
Old 08-06-2017, 01:37 AM   #63
a4z
Senior Member
 
Registered: Feb 2009
Posts: 1,377

Rep: Reputation: 589Reputation: 589Reputation: 589Reputation: 589Reputation: 589Reputation: 589
Quote:
Originally Posted by Peverel View Post
Well, NevemTeve has introduced an interesting point of semantics.....
not really
don't get confused, or let confuse you
a pointer to a pointer is just a pointer, to a pointer ;-)
this can be chained as deep as you like

Code:
#include <stdio.h>

int main(void) {
	char* a = "hello" ;
	char** b = &a ;
	char*** c = &b ;
	char**** d = &c ;
	
	printf ("%s \n", ***d);
	return 0;
}
pointers to pointers are not uncommon i C as function arguments, and not only used for arrays.

in case of argv it is just a pointer to an array, this can be written

Code:
char *argv[] 
//or 
char **argv
since C allows this.
C was never evolved to a language the removes its flaws, it was invented to solve a problem, than it was there, than the creators moved on to other problems, and today we have to live with this kind of a technical debt.
 
Old 08-07-2017, 08:52 PM   #64
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,326
Blog Entries: 4

Rep: Reputation: 2841Reputation: 2841Reputation: 2841Reputation: 2841Reputation: 2841Reputation: 2841Reputation: 2841Reputation: 2841Reputation: 2841Reputation: 2841Reputation: 2841
In my usage of the term, data structure, I specifically did not equate it to "a struct." In fact, this interpretation would be fundamentally incorrect.

A "data structure" is any arrangement of data – in memory or otherwise – that is done to facilitate the computer's subsequent access of it. The "things" which comprise that structure are sometimes, but not always, multi-byte "things" which are most-conveniently described as structs.

struct is a semantic device, found in nearly every programming language, which is used to describe a grouping of related variables which occupy a necessarily-contiguous group of bytes. Sometimes, more than one struct definition is applied to the same group of bytes, and the language has no means to know which of these is "correct."

I would consider a struct to be, shall we say, merely a "data block," because it is a single thing ... "structured within itself," yes, but (perhaps) only part of a "data structure." structs are customarily found as the building-blocks of a data structure.

Last edited by sundialsvcs; 08-07-2017 at 08:55 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
redeferenced pointer to incomplete type Aldair1808 Programming 1 11-28-2005 03:23 PM
list<type> how can I make type be a pointer? exodist Programming 2 06-06-2005 08:40 AM
returning data to main() via a pointer to a pointer. slzckboy Programming 3 05-30-2005 01:20 PM
ereferencing pointer to incomplete type? ams Programming 5 03-03-2005 10:32 AM
Getting an incompatible pointer type error... JStew Programming 4 03-06-2003 05:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration