• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Question of adjacency list  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am gonna create adjacency list and insert note and edge. I have to check if the node exists before inserting a new node. If yes, it will print ExitedNode. However, there is error in the last code of my insert method which is "incompatible type in assignment of char to char[100]". I dont know how to coorect it meanwhile does my logic of whole insert method correct?

 
Marshal
Posts: 64494
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is something wrong about the declaration of the parameter, I think.
Line 16. I think char n[100] should read char[] n or char n[] without the size. Or probably better char *n, but n is hardly a good name for a string.
You have some other names which I think are poorly chosen, like a list called g..
 
Ranch Hand
Posts: 165
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Haven't checked all the logic but line 29 needs to be a strcpy() doesn't it?

 
Campbell Ritchie
Marshal
Posts: 64494
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please go back and indent your code carefully; you have too many }s at the extreme left of the page, some of which should be farther to the right. That makes it hard to follow the flow of execution, particularly near line 40. Is line 41 supposed to be in the else or not?
 
Steffe Wilson
Ranch Hand
Posts: 165
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You haven't allocated any memory for your data structures such as g, p or p_Node. Lookup malloc().
 
When you have exhausted all possibilities, remember this: you haven't - Edison. Tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!