Page 1 of 1
is older C compiler version available
Posted: 21. Nov 2013, 21:05
by atlantis43
Hi:
Is there any way to get an edition of VB which will compile gets()?
I'm trying to learn C programming from a text that has many code examples which include that function, and would prefer not to have to recode each example with fgets(). Recently downladed VB, and discovered this problem, and would really appreciate a work-around.
Thanks for your attention.
Richard
Re: is older C compiler version available
Posted: 21. Nov 2013, 21:40
by mpack
Eh? VirtualBox doesn't include a C compiler of any description. You install an operating system inside a VM. Then you can install a freeware C compiler if you wish, but that's not a VirtualBox topic.
I'll give a quick hint: gets(x) is just shorthand for fgets(x,MAXINT,stdin). In modern C gets() is replaced by gets_s() which has an extra mandatory parameter giving the size of the dest buffer. Supply that size and you should be fine, and it's very much recommended that you get into the habit of always providing a dest buffer size. Do it the right way from the start and you won't live to regret it (which you will if you allow the potential for buffer overflows).
Re: is older C compiler version available
Posted: 21. Nov 2013, 22:13
by atlantis43
I forgot to mention that the compiler command line I'm using is:
Code: Select all
clang -ggdb3 -O0 -std=c99 -Wall -Werror
Is there anyt way to alter this so that it will accept
gets().
It's not that I'm lazy, but just trying to simplify the learning process so that I don't have to alter every code example in the learning process.
The compilation failure for
gets() has already made me aware of the replacement by fgets() or getline().
Re: is older C compiler version available
Posted: 22. Nov 2013, 01:23
by mpack
Sorry, these are the VirtualBox forums. I'm sure you can find a more appropriate forum to discuss C programming. I gave you a "quick hint", that's as far as I'm willing to go with a clearly off topic discussion.