> I need help with error: gets (str); Problem description: Function 'gets' could not be resolved.
Because gets() has been permanently banned from ever appearing in any more programs.
What compiler are you using? Do you realize that that dangerous C function is no longer part of the C standard and your C++ compiler may no longer support that exceedingly dangerous C function?
Enter a string: This is a test
Before reversing: This is a test
After reversing: tset a si sihT
Before reversing: This is a test
After reversing: tset a si sihT
salem c, just wanted to say I love your wording of the function being "permanently banned" :D
Usually people just go with the boring "deprecated" wording.
The gets() function does not perform bounds checking, therefore this function is extremely vulnerable to buffer-overflow attacks. It cannot be used safely (unless the program runs in an environment which restricts what can appear on stdin). For this reason, the function has been deprecated in the third corrigendum to the C99 standard and removed altogether in the C11 standard. fgets() and gets_s() are the recommended replacements.
Never use gets().
I'd call the possibility of buffer-overflow attacks as being a security risk.
What do you think is the benefit of using gets_s() over fgets()? Remember that the stdin is a file.
Edit: And yes I saw that you had multiple methods, but IMO mixing C++ io with C io is a poor practice. If you're going with stdio for input stick with stdio for output as well.
You chose to quote only half of what I said:
Because I was only pointing out that the "safe" stdio functions are optional and are not available with all compilers, the rest of what you said was on point.