Quote:Original post by ZahlmanQuote:Original post by Anonymous PosterQuote:Original post by Zahlman
0) For something like this, there is very little justification I could accept for "I have to use C" - except possibly "I'm doing this for school and my prof is stuck in the 80s". Although a prof stuck in the 80s wouldn't speak of ZeroMemory() but instead memset().
1) In particular, if you can't figure out these kinds of things for yourself, you have no business trying to do them in C. It's not as if there's any significant amount of fat *available* to trim out of a standard C++ (using the standard library) implementation, and there are much better ways to learn how low-level algorithmic ideas.
</holierthanthou>
"If you can't figure out these things for yourself, you have no business blah blah...."
If you can't figure out these things for yourself you have no business learning them? Hello? He's obviously taking some kind of course here...
It is my considered opinion that very few people in the world have any business doing anything in plain C these days, at all. In a great majority of cases, the extra work done and mental burden taken on (versus using C++ and taking advantage of the full standard library) are ridiculous for no performance benefit whatsoever; in a great majority of the remaining cases, the performance benefit is barely measurable and the extra work is still ridiculous; in almost every remaining case after that, the performance benefit is not enough to matter while the burden would still be eased significantly by things like built-in-to-the-language RAII. C++ can be treated, to a large extent, like a preprocessor for C which is orders of magnitude more powerful than the built-in one, and that's still not harnessing the full power of the language. And if you're one of those oddballs using C99 explicitly for the few minor changes that actually let you do very specific optimizations that C++ won't trust you to do... then you'd probably have more luck writing it in FORTRAN.
Seriously, the only real excuses for using C that I can consider are "a C++ compiler does not exist for the target platform" or (which usually goes hand-in-hand) "the target platform requires the final executable to be smaller than what is realizable if I include <iostream>".
Lots of profs - colleges - programming curricula in general - have some *very* strange ideas about how to teach "a deep understanding of the machine". (At least, I hope that's what they're after. I shudder to think that they expect to teach people *how to program* like this! Absolutely disgusting.) It's better done via instruction in what they call "computer organization", which might (but needn't) get as high-level as an introduction to some form of assembly language (the one chosen doesn't matter).Quote:
The code is all mine EXCEPT for the function protos. It HAS TO BE, NO QUESTION ASKED void**
See? Pure idiocy. Nothing is gained by throwing away the idea of *data types*. In fact, this idea is *fundamental* to programming. And there's no reason the function can't accept a StackNode** instead, because that's the only kind of pointer it will *ever* receive. Nothing else is valid. Notice that the dereferenced parameter is cast to StackNode* *unconditionally*.
Please, PM me contact information for your prof (and/or the department of computer science, if appropriate). I am volunteering - with discretion assured, and at no cost and assuming full legal responsibility - to tell him/her/them off.
For someone who only recently learned what actually happens if you use the & to take an address of an array you sure sound high and mighty up there.