2

gets_s() function is not working on my compiler. I am using codeblocks with GCC.

This is the error :

undefined reference to '_imp_gets_s.

Can anyone please tell me how to resolve this error.

Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261
jashan
  • 41
  • 5

1 Answers1

7

You should be using fgets() over gets() or gets_s().

Referrring C11, §K.3.5.4.1, paragraph 6,

The fgets() function allows properly-written programs to safely process input lines too long to store in the result array. In general this requires that callers of fgets() pay attention to the presence or absence of a new-line character in the result array. Consider using fgets() (along with any needed processing based on new-line characters) instead of gets_s().

Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261