is older C compiler version available

This is for discussing general topics about how to use VirtualBox.
Post Reply
atlantis43
Posts: 26
Joined: 28. Oct 2013, 07:04

is older C compiler version available

Post 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
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: is older C compiler version available

Post 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).
atlantis43
Posts: 26
Joined: 28. Oct 2013, 07:04

Re: is older C compiler version available

Post 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().
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: is older C compiler version available

Post 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.
Post Reply