HELP: gets() statement not working in C++
I was wondering why I am producing an error on line 11 of this code. In Microsoft Visual Studio 2010, this code runs fine. However, the gets() statement will not function properly on repl.it. Does anybody know the error or bug?
the gets() function in c++ (template: char gets(char str)) is included in the <cstdio> header. Include that, also what goes in the parenthesis of gets() is the output variable, not the specific location you want. You need to use an if statement to call gets() when the location you want comes up. You also need to declare whatever variable you put in the parenthesis as your output variable.
This function was actually deprecated at some point I’m pretty sure. Your other compiler is either behind in standards, or just wanted to keep it. Either way it’s not a steady thing to count on any more so use fgets. (fgets is basically used the same way Umbra used it, but now you also pass the FILE stream and the number of chars you wish read.)
If you’re too attached to gets, just make a macro, but don’t depend on gets anymore it’s not viable.
@Highwayman its a complete shame that iso/iec standards, especially with the case of iso/iec 9899, are not published freely in their final form. i wanted to check out iec 9899:2018, and unlike ecma262 and others, i cant just read it - there is a paywall
it makes learning c far less enjoyable