Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

linked list

Posted on 1999-06-26
4
Medium Priority
?
189 Views
Last Modified: 2013-12-14
how we scanf if we have
struct stock{
char name;
struct stock *next_stock;
}goods;
struct customer{
char add;
struct goods things;
main()
{
scanf("%d",cust->?????????????????)






struct customer *next_cust;
}cust;
0
Comment
Question by:eddyhalim
[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
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
BudVVeezer earned 20 total points
ID: 1263024
cust.things.name

since things is a part of the struct(not a pointer), you would use the ., not the ->.  If things was a pointer to a goods, then you would use the arrows.

~Aaron
0
 
LVL 3

Expert Comment

by:BudVVeezer
ID: 1263025
btw, an easier definition would be:

typedef struct goods
{
char name;
struct goods *next;
}goods;

typedef struct cust
{
goods *things;
struct cust *next;
}cust;

then you would do

cust c;

c->things->name;

~Aaron
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 1263026
WATCH OUT!
Your "name" is only one character long

#include <stdio.h>
/**/
typedef struct goods
{
      char            name[50];
      struct      goods *next;
}goods;
/**/
void main(void)
{
      static      goods      xGoods;
      static      int      iResult;
      
      iResult = scanf("%s", xGoods.name);
      /*You will have to calculate the address of the next goods manually*/
      printf(" %d Fields converted\r\nYou entered:\r\n\t%s\r\n", iResult, xGoods.name);
}
0
 

Expert Comment

by:prabhuram
ID: 1263027
If you want each element of the linked list cust to have a linked list goods, what the hell do you want to read as input and populate what fields? all of them in sequence?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
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.

721 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