2 ms·
I learned C programming in 1987 using Turbo C. I recovered several small programs I wrote for the C class and converted them to work on GCC under Ubuntu. Most
by orionblastar 14y ago
I learned C programming in 1987 using Turbo C. I recovered several small programs I wrote for the C class and converted them to work on GCC under Ubuntu.
Most of the code didn't need changes, except where it handled strings (or the char *string1 type string) because somehow gets() caused a segment fault and when I switched to scanf() it worked without crashing. When I used the math.h library and the sqrt() function I had to use the -lm switch on the compiler to get it to work.
I rewrote them in C++ using the G++ compiler and found that the std::string works better than the old C string, and that the cin and cout commands work better than gets and scanf.
I really don't see much of a problem unless you are converting Pre-ANSI C code to the current standard or something. I think that the scope changed, but back in 1987 we were taught to keep variable names used in functions inside of functions, etc to keep the scope the same and don't try to access something out of scope. I guess that is why my programs converted so easily? They also didn't need a lot of resources or libraries and were simple programs written for the command line for DOS using Turbo C.
Should I use CLANG or LLVM instead? How about Visual C++ or Borland C++? Am I doing wrong trying to learn GCC and G++ or should I try learning under a different C++ compiler?
- iso-8859-1 14y agoWhy not just write code for the standard? Unless you are using your own stdlib or something, it shouldn't matter much what compiler you use.