c++ struct arrays

Programming, for all ages and all languages.
Post Reply
slacker

c++ struct arrays

Post by slacker »

does c++ have the capability of arrays of structs? like:

structname s[100];

and then you can:

s[1].amount=100;
Tim

Re:c++ struct arrays

Post by Tim »

Well, maybe you could tell us.
slacker

Re:c++ struct arrays

Post by slacker »

it compiles fine...
Tim

Re:c++ struct arrays

Post by Tim »

Good. What do Kernighan & Ritchie, or Stroustrop, say?
slacker

Re:c++ struct arrays

Post by slacker »

i have no idea. who are they?
The Pro from Dover

Re:c++ struct arrays

Post by The Pro from Dover »

Dennis Ritchie and Brian Kernighan were the two original designers of C (Ritchie was also one of the designers of Unix, along with Ken Thompson), and authors of the definitive text on it, The C Programming Language. Just about any reference you'll see to "Kernighan and Ritchie" (often abbrieviated as "K&R" is going to refer to that book, which is standard reference on C. You'll also see references to "K&R C", which refers specifically to the version of C defined in the first edition of K&R (which was quite different in certain respects from the ANSI C now widely in use, and which is covered in the second edition K&R).

Bjarne Stroustrup was the primary designer of C++, and author of another book, The C++ Programming Language. Like with K&R, most references to 'Stroustrup' are to the book, usually the most recent edition.

A quick google search would have found most of this quite easily, of course. I'd also recommend reading through the Jargon File, as it is filled with this sort of lore, and funny as hell besides; I would, however, take the entries with a grain of salt, as ESR uses the File as something of a bully pulpit these days.
Tim

Re:c++ struct arrays

Post by Tim »

More so The Art Of Unix Programming, which is full of apparently made-up statements about Windows NT. I had to stop reading after I learned that programs had no standard way of accessing the Registry.
The Pro from DOver

Re:c++ struct arrays

Post by The Pro from DOver »

Tim Robinson wrote: More so The Art Of Unix Programming, which is full of apparently made-up statements about Windows NT. I had to stop reading after I learned that programs had no standard way of accessing the Registry.
True, but AoUP is unequivocal propaganda; it's stated purpose is to convert you to the Unix Way. The Jargon File is supposedly a more objective work, meant to reflect hackerdom ('hackers' in the older sense of wizard programmers, not in the sense of electronic tresspassers) as a whole, not just the Unix and Open Source communities. While he's done a reasonable job of it, his strong opinions come through, more and more over time. Also, he's not immune to stroking his own ego, as shown by the entries for 'Halloween Documents' and 'Anti-Idiotarianism', two things he was personally responsible for and which no one else gives half a damn about anymore (or, in the latter case, ever did). Don't get me wrong; he's usually pretty fair and balanced, and is rather concienscious about what does and doesn't go in the File (and he uses a fairly light touch in moderating the Jargon-Helpers list). However, he's definitely human, and as full of his own ideosyncrasies as any of us.

As for his statements about Windows, well, he's probably following something he was told by someone else; he wouldn't know otherwise, as I get the impression that he has never even used Windows, of any version. I doubt he's ever used anything other than Linux since 1995, actually; he certainly has no notable experience with MacOS (what he says about that is at least as absurd as what he says about Windows).

Also, that whole section of the book was very obviously using Windows as a wicker man; one can see the set up coming from the very beginning of the chapter. No other OS he talks about, not even MVS, is so thoroughly excoriated as Windows is.

Fortunately, he shuts up about other OSes for the rest of the book (at least what I've read of it) and gets down to the serious business of discussing how perfect Unix is. Despite the overwhelming flavor of favoritism, it actually has quite a bit of interesting insight into Unix, and programming in general. Very little of it is original (though he gladly gives credit where credit is due), and I disagree with a great deal of what is his own material (esp. the self-serving way he endlessly uses his pet utility, [tt]fetchmail(1)[/tt], as an exemplar of The Unix Way). Much of it is interesting nonetheless, and his prose style is pleasant enough, once you get past the smugness. I do hope he gets a nice, ruthless editor to work out on it before it goes to print, however.
Post Reply