Hi,<p>C newbie here. I'm trying to dig into C so I can do more things other than just web development, like Linux kernel development or systems development.<p>Rust also looks promising, but I'd like to learn C first.<p>I already got pointers, or rather, some of it:<p>http://sprunge.us/DcWS?c<p>However, I'm still not sure about structs, anyone please?<p>Book suggestions are also welcome.
Structs can be looked at like any other collection of data items grouped together under a specific name. Different languages call the grouping by different names: so you might find amongst the languages words like:<p>COBOL - record, SQL - row, Excel - row, C - struct, etc.<p>If you only know Java, a (very) rough 'n' ready conceptualization might be an object that has data items, but no methods at all.<p>A struct pointer will point to the start of each struct only, and incrementing the pointer will point to the start of the next struct in the array (if one exists). Within that struct the separate field will be only pointed to by a '->' thus 'str_pointer->item0'.<p>Note also that you can use the name itself of the struct (which in reality is also a pointer, but is usually not considered as such), in this case the item is selected by using a '.' thus 'str_name.item0'<p>The biggest problem I had in learning structs was the difference between the '.' and the '->' syntax. I already knew what a record or a row was.
Have you tried looking at "Learn C the Hard Way"? Here's their section on structs:<p><a href="http://c.learncodethehardway.org/book/ex16.html" rel="nofollow">http://c.learncodethehardway.org/book/ex16.html</a>