?
Solved

Naming Singly Linked List

Posted on 1997-10-10
1
Medium Priority
?
181 Views
Last Modified: 2006-11-17
I am trying to figure out how to name a singly linked list.
For example, if I am doing a quadratic polynomial and I have defined a structure such as this:

typedef struct poly_node *poly_pointer;
typedef struct poly_node
{
int coefficient;
int exponent;
poly_pointer link;
};

Then in the main part of the program. I want to ask the user what is the name for a certain polynomial which may look like this:

main ()
{
printf("Enter a name for this polynomial: ");
scanf("%s", name);
.....

}

The question is how do I make the reference in naming that polynomial? I don't want to put the name in the struct because each node will want to have a name. The thing I am trying to do is that...I just want to make a reference to that named polynomial such that if I want to add two polynomial together and call that function to add:

addpoly(a,b);

where a and b are individual polynomial. how do I approach this problem???
0
Comment
Question by:ricco
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
nate091597 earned 150 total points
ID: 1255827
Add another structure, e.g.,

typedef struct polynomial
{
    char name[50];
    poly_pointer link;
} polynomial;

Then you can write

polynomial the_poly;
scanf("%s", the_poly.name);

as well as

polynomial *addpoly(polynomial *a, polynomial *b)
{ /* adding code here */ }

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question