This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Question of adjacency list

 
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: 69894
278
  • 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: 69894
278
  • 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().
 
Poop goes in a willow feeder. Wipe with this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic