Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: 93NickCousar on September 16, 2018, 10:33:35 pm
-
I'm trying to do some of the practice exercises in Kernighan & Ritchies The C Programming Language (2nd Edition), which was published in 1988. Most of the practice problems do not output as intended. I'm not sure why, but I think it may have to do with the C standards that the GCC compiler follows. This book was almost certainly written before the C99 standard was implemented so I think that is what is causing some of the programs to not run properly. Anyways, I was wondering if there was some setting in Code::Blocks I could change that would allow for programs written with an older standard of C to still be compiled correctly. This dialog box in the Project>Build Options tab looks promising, but I don't know which box to check. Would changing any of these settings work?
(https://i.postimg.cc/bvR9yB9J/compset_2.png) (https://postimages.org/)online pic hosting (https://postimages.org/)
-
Throw away that book and get a recent one. Unless you work in a museum and prepare an exhibition. You can try the lowest language revision CodeBlocks offers (the numbers are years, 90 == 1990, 11 == 2011), but im not sure if any non-ancient gcc implements that old standard of that book anymore.
But depending what not outputting as intended is i doubt the standard has do much of an influence, it does have an influence to get the programs to compile and not crash instantly.
-
Try "-std=c89" or "-std=c90" they are likely the oldest supported by most recent GCC compilers.
For better answer ask on a site that supports the compiler you are using.
Edit2: Offsite link added https://gcc.gnu.org/onlinedocs/gcc-8.2.0/gcc/Standards.html#Standards (https://gcc.gnu.org/onlinedocs/gcc-8.2.0/gcc/Standards.html#Standards)
Tim S.
-
Throw away that book and get a recent one.
Can you recommend a book for a first year CS student? Perhaps something that goes into the theory/rationale behind certain programming concepts, and how they are implemented in C? I could also use a good reference book for specific rules and syntax.
-
Without telling us what errors you have we can not help you much, but it is very unlikely that your runtime problems come from different c standards. Maybe your book is accessing raw memory? If there are differences then it is a operating system thing. C standards make the most difference on compile time. On runtime all should behave the same (minus some weird bugs).
-
Can you recommend a book for a first year CS student?
I am not a reading guy, i am more a doing guy. I never read any "how do i start programming in x" book and first year CS is far behind me, so i can't recommend anything up-to-date here. The last books i bought and partly read have been Effective C++ and Effective Modern C++, but i think these are not your topic right now (plus they are not about C but C++ only).
I could also use a good reference book for specific rules and syntax.
Now here i can deliver, my most favorite one is https://www.cppreference.com (https://www.cppreference.com), despite the name it also covers C. Another one is http://www.cplusplus.com (http://www.cplusplus.com) but its not so good like the first one IMHO.