473,405 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Difference Between Data Structures and Pointers

Hi,

I always had a doubt regarding the difference between pointers and data structures... Could anyone give me the clarification...
Oct 31 '06 #1
6 7531
vimase
5
Hi,

I always had a doubt regarding the difference between pointers and data structures... Could anyone give me the clarification...
Pointers are constructs that point to the address location of a particular data type. Ofcourse, pointers also need to have data types associated with them, i.e. while declaring we have to define the data type of the pointer, for e.g.
int * p;
char * p1;
but the pointer is just pointing to the memory location, which holds the particular variable. So by just changing the reference of the pointer, the same pointer can point to any variable of that particular data type.
Oct 31 '06 #2
Pointer is a variable which holds the address of another variable.................
int *p; which means...
1)p is a variable which holds the address of integer variable
(or)
2)p is a pointer points to an integer

so pointer hold the address of a variable accordingly.

Data structure:
the organization of data (and its storage allocations in a computer)
in data structure pointers are widly used... as pointers deals vth da memory adress.....we can easily organise data using pointers.
Oct 31 '06 #3
pointers are "constructs"...
what are "constructs"?
Dec 9 '13 #4
good explanation disarisikar
Dec 9 '13 #5
Sherin
77 64KB
DATA STRUCTURE

Structure refers to a collection consisting of elements of heterogenous data type
Structure uses “.” (Dot operator) for element access
Instantiation of Structure objects is possible.
Bit filed is possible in an Structure.
Structure is a user-defined datatype.


ARRAY


Array refers to a collection consisting of elements of homogenous data type.
Array uses subscripts or “[ ]” (square bracket) for element access
Instantiation of Array objects is not possible.
Bit filed is not possible in an Array.
Arrays is a primitive datatype
Oct 2 '20 #6
Banfa
9,065 Expert Mod 8TB
Not incorrect @Sherin but the question was difference between a structure and a pointer not a structure and an array.

Note that arrays are not pointers in several very significant ways. Sometimes, because the name of an array variable used alone decomposes to a pointer to the first element of an array people confuse pointers and arrays but it is better not to.

For example using the sizeof operator the sizeof an array is the actual size of all the data in the array so that sizeof array/sizeof array[0] is the number of entries in the array. Size of a pointer is either 4 or 8 or less often now 2 (depending on your platforms pointer size) sizeof pointer/sizeof pointer[0] is meaningless.
Oct 2 '20 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Sebastian Kemi | last post by:
How should a write a class to a file? Would this example work: object *myobject = 0; tfile.write(reinterpret_cast<char *>(myobject), sizeof(*object)); / sebek
22
by: Ook | last post by:
We have had a discussion on the differences between a class and a structure, and no one is in agreement. As I understand it, a structure defaults to public, a class defaults to private. There are...
6
by: nick | last post by:
I have tried finding an answer to this, but most people just explain classes as a more modular way to program. It seems to me that (forgetting OO programming which I don't quite understand) the...
18
by: Markus.Elfring | last post by:
The C++ language specification provides the key word "mutable" that is not available in the C99 standard. Will it be imported to reduce any incompatibilities?...
5
by: Alfonso Morra | last post by:
Hi, I am writing a messaging library which will allow me to send a generic message structure with custom "payloads". In many cases, a message must store a non-linear data structure (i.e....
5
by: Chris | last post by:
Hi, I don't get the difference between a struct and a class ! ok, I know that a struct is a value type, the other a reference type, I understand the technical differences between both, but...
6
by: James | last post by:
I am using vb.net and need to keep in memory a large data structure, so I am looking for the best option. And after several test I am pretty confused. So I will be grateful if anyone can help me. ...
11
by: efrat | last post by:
Hello, I'm planning to use Python in order to teach a DSA (data structures and algorithms) course in an academic institute. If you could help out with the following questions, I'd sure...
7
by: pereges | last post by:
I've to store an array of structures: typedef struct { double origin; double e_field_at_origin_real, e_field_at_origin_imag; double direction; double pathlength; int depth; }ray;
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.