473,396 Members | 2,014 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,396 software developers and data experts.

help with this struct

I cant understand what does the 4th line do in this snippet

//struct byLightning * pPrevNode;

typedef struct byLightning
{
int data;
int nodeNum;
struct byLightning * pPrevNode;
} LIST_NODE;

Thanks for any responses....

Jul 18 '06 #1
6 1194
le*******@gmail.com wrote:
I cant understand what does the 4th line do in this snippet

//struct byLightning * pPrevNode;

typedef struct byLightning
{
int data;
int nodeNum;
struct byLightning * pPrevNode;
} LIST_NODE;
It contains the opening brace which begins the structure definition. You
probably didn't have a problem with that 4th line, so please specify
which 4th line you really meant.

Richard
Jul 18 '06 #2
On 18 Jul 2006 08:01:57 -0700, in comp.lang.c , le*******@gmail.com
wrote:
>I cant understand what does the 4th line do in this snippet
Which 4th line? The opening curly brace, the int nodeNum or the
structbyLightning one? [all of these are the 4th line, counting from
somewhere in your post...]
>//struct byLightning * pPrevNode;

typedef struct byLightning
{
int data;
int nodeNum;
struct byLightning * pPrevNode;
this declares a pointer to the previous node in the linked list. If
you're not sure what a linked list is, you probably need to get a good
C textbook.
} LIST_NODE;

Thanks for any responses....
--
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
Jul 18 '06 #3

<le*******@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
>I cant understand what does the 4th line do in this snippet

//struct byLightning * pPrevNode;

typedef struct byLightning
{
int data;
int nodeNum;
struct byLightning * pPrevNode;
} LIST_NODE;

Thanks for any responses....
Well, let's see. First, I'll assign line numbers, so I can figure out
what you are talking about:

1 //struct byLightning * pPrevNode;
2
3 typedef struct byLightning
4 {
5 int data;
6 int nodeNum;
7 struct byLightning * pPrevNode;
8 } LIST_NODE;

The 4th line is an opening curly brace for the stuct definition.

--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Software Reuse Project

Jul 18 '06 #4
le*******@gmail.com schrieb:
>
I cant understand what does the 4th line do in this snippet

//struct byLightning * pPrevNode;

typedef struct byLightning
{
int data;
int nodeNum;
struct byLightning * pPrevNode;
} LIST_NODE;

Thanks for any responses....
Try to understand linked lists.

--
"Careful with that VAX, Eugene!"
Jul 18 '06 #5

le*******@gmail.com wrote:
I cant understand what does the 4th line do in this snippet

//struct byLightning * pPrevNode;

typedef struct byLightning
{
int data;
int nodeNum;
struct byLightning *pPrevNode;
} LIST_NODE;
This is a self-referral structure. The third member is a pointer to an
object of same type as the structure itself. The declaration of the
third member is ok because the base type of the pointer is known, at
that time the info of the type is enough to declare a pointer. All
pointers are the same and have the same size.

Jul 19 '06 #6
lovecreatesbeauty wrote:
>
le*******@gmail.com wrote:
>I cant understand what does the 4th line do in this snippet

//struct byLightning * pPrevNode;

typedef struct byLightning
{
int data;
int nodeNum;
struct byLightning *pPrevNode;
} LIST_NODE;

This is a self-referral structure. The third member is a pointer to an
object of same type as the structure itself. The declaration of the
third member is ok because the base type of the pointer is known, at
that time the info of the type is enough to declare a pointer. All
pointers are the same and have the same size.
Not necessarily true.

My recollection is that all /struct/ pointers must [1] be the same size
(as a consequence of things the Standard says). But there's no
requirement that an int* and a char* are the same size, or that
a function pointer be the same size as a void* -- it could be smaller
/or bigger/.

[1] Up to "as if".

--
Chris "seeker" Dollin
"Life is full of mysteries. Consider this one of them." Sinclair, /Babylon 5/

Jul 19 '06 #7

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

Similar topics

4
by: cpptutor2000 | last post by:
I am trying to create a simple linked list. The source code is provided below. I receive the following error message: (Please see after source code). I have marked the lines where the error occurs...
2
by: Foodbank | last post by:
Hi everyone, I'm having trouble implementing a supposedly simple Least Significant Digit first Radix Sort. The book I'm using gave me somewhat of a template that I touched up (below), but I'm...
6
by: TC | last post by:
Hi. I write a program in c language that read a text file and extrapolate the word. for all word the program calculate the number of the times that word is present in the text. The problem is the...
2
by: duncanblacksmithmath | last post by:
I know a lot of you have seen this before but I have worked on the program and have gotten it to work thus far but I need help getting these two functions to work and implementing them. Here is...
9
by: Danny Mavromatis | last post by:
I have a chunk of VC.NET code (below) that I need to convert to VB.NET syntax. Could someone help me get started? I'm new to structures and unions and I don't understand how to nest then in...
4
by: Steve Chow | last post by:
I was wondering if someone could help with my assignment. I've pretty done finished the work but cannot figure out why it only prints the last one added. Here is my code. The way things are done...
14
by: fool | last post by:
Dear group, Thanks for all those who helped previously. Now I get some value printed. Is that the value of the list getting printed? Am I really polluted the list? Previous thread link...
1
by: Zhiyao | last post by:
I want to write a program which can read strings, one per line, from standard input, and the program builds a list of strings then prints it. The code is listed below, when I compile it, there is no...
4
by: jadeivel756 | last post by:
I BADLY NEED YOUR HELP...... HELP... hOW TO Pass value to a struct type and permanently store the data after youve given the data.The programming language is C. My problem is that as I exit the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.