Many times I define a class and soon I will feel the design is bad, making the problem more complex. Sometimes I define a lot interfaces today and change all my minds tomorrow and re-write them all.
That problem won't really go away if you switch to pure C, though, except that you obviously won't be writing any classes. Instead you'll write a set of functions operating on a certain type of data and then change your mind the next day and rewrite them all.
So I want to know how does professional C programmer write their daily codes? For example, when a linked list is used to organize some data, will you directly operate the pointer to next node in the application's algorithm, or will make an abstraction to hide the details of linked list?
There are probably various third-party libraries available that provide somewhat generic data structures such as lists and so on. It's just that in C, "generic" usually means mucking around with void-Pointers and constantly casting to the type of data you're using the structure with.
Really thanks for your replies.
Actually I am doing exact things you descripted: writing function to operate some data, as a class in C++, but with functions. From some books I read that abstraction is important because it decreases the complexity. But I always feel it's hard to do it. Sometimes I think programming without abstraction, just use plain data, may be more efficient, as I can waste less time designing interfaces and abandon thems, and may feel less frustrated.
Maybe I read wrong book. Books I read always tell the concepts, list a lot of its advantages but doesn't teach how to really do it. Even SICP, I read the two chapers and half the third chapter and did the most exercises in these chapters, doesn't help a lot. I feel the programs in these books are always too ideal or just toy programs. But practical programs are more dirty. Do you have some recommended books? Or should I read some sources code of open source projects?
And actually my point is not whether there are some third-party library for C. I'm asking whether professional C programmers write some general data structure once and use them frequently after (or just use some third-party libraries), or just combine these data structures into the applications' algorithm?
Library development is common in programming. It is the process of building on abstractions. It sounds like you're asking if C programmers use libraries to which the answer is simply "yes".
Now, I'm more confused about why you want to use C instead of C++. You have already said you're using a C++ compiler and IDE. It sounds to me like you are running against issues with learning the language because you perceive it to be harder than to continue on with what you know. It doesn't sound like you're making this choice for any actual technical reason.
I can assure you that while in the short term it may be easier to hack out a few hundred lines of code (rather than learn the standard library) it won't pay off long term. Implementing your own container classes might feel more comfortable, but it is also much more likely that you're introducing memory leaks and probably lacks the efficiency of the STL (it's hard to beat a couple decades of testing and design even for specific applications of problems by seasoned programmers, and impossible to when you're first learning the language).
It sounds like you're in need of a good book, or a complete change in language (maybe try python or something else). There is very little reason to restrict yourself to C in this day and age, maybe only for some specific embedded systems does it make sense. The power of templates and the benefit of classes and the standard library is huge (not to mention boost and other C++ libraries).
Finally, and probably most fundamentally, C is not a great language for container classes primarily because of the lack of template support. You can simulate object oriented programming in C by passing around structs to functions which modify state, but it's harder to simulate std::vector or std::list type functionality primarily because the underlying methods do not exist in the language. That is, in fact, the primary reason C++ exists. It offers a lot of extra stuff that C simply does not, much of that is directly a result of why you are asking this question now and are unsure about library development.
There are quite a few high quality C libraries for specific purposes, but it is a lot harder to write good generic code for C. Generic C code often involves a lot of void* casting or macros.
So now that I've given you the advice you actually need, I'll tackle the advice you asked for.
Here's a decent rundown of a few options for C libraries: http://programmers.s...t-library-for-c
And more specifically here is a generic macro based container library: http://sglib.sourceforge.net/
Ultimately the question you've got to ask yourself is: if I download a non-standard library and invest time in reading and understanding how to use it then what am I REALLY gaining over simply biting the bullet and learning a little more about the C++ standard library?