On 05/08/2015 10:18, Fernando Rodriguez wrote: > You can look at it like that, but more technically it's because C doesn't > support out arguments, or reference arguments, or objects. All arguments are > passed by value. You can return multiple values in a struct but it's not very > convenient both in terms of usability (you need to store the result in a > variable before you can use it unless you only care about one member) and > performance since everything needs to be copied. Plus the implementation may > vary significantly between compilers and architectures > > So in order to get a value back from the function (other than the return) you > pass the address (a pointer) where you want that data to be written. Things > like that make C seem primitive if your coming from a higher level language > but it is what makes C so powerful. Once you get the hang of it and > understand > how everything works it's actually simpler than higher level languages > because > C doesn't do stuff behind you back (or does very little) so you can read C > code > a understand what's going on under the hood. Most Java and .NET developers > for > example have no clue about what goes on in their own programs under the hood.
Thanks for the reminder. I'd forgotten much about C (not needing to read or write it much these days) > >>> > > >>> > > In this context does '&hostname' mean a-pointer-to-a-pointer-to-the- >>> > > charstring we actually need? >>> > > >>> > > Doesn't this code seem needlessly complicated? >>> > > >>> > > <okay, screed over, thanks for listening> >>> > > >>> > > Somewhere I read that there was really only *one* java program ever >>> > > written, and every subsequent java program was written by cut-and-paste >>> > > from the first one. >>> > > >>> > > Is that how professional developers learn the art of programming? Looking back 12 months to some former colleagues, that is *exactly* how the Java ecosystem works. I haven't seen anyone write Java from scratch in *years* now, all of them seem to twiddle little bits inside some huge framework and have zero concept about what is going on. So you get anomolies like a giant payroll/compensation/commission reporting tool thingamagic from Oracle that does everything imaginable about sales commissions, except actually report on them. True fax - ask my wife > That's how you write bugs :) There's nothing wrong with it if you take the > take to understand what it's doing but it's too often done blindly. > >>> > > I really would like to hear your opinions on that question because I >>> > > feel it's an important topic. Much of what makes programming work has been dumbed down in recent years so that employable persons without imagination[1] can have jobs and do something useful. I'm reminded of an old saw about PHP: The nice thing about php is it let's everyone and their dog write code. The bad thing about php is that they do. I suppose there's a place for that kind of thing, a lot of corporate systems are mostly boilerplate where a huge framework (and equally huge expensive over-specced hardware) gets the job done. The thing that really changes is the exact calculations in the business-logic middleware layer, someone else did the heavy lifting of joining all the modules together to resemble the real-world workflow. It's not my way of working though, and I suspect most Gentooers tend the same way if they get the chance. -- Alan McKinnon alan.mckin...@gmail.com