Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: use strcpy_s instead of strcpy

...

This compliant solution uses different, more descriptive variable names. Also it uses strcpy_s.

Code Block
bgColor#ccccff
char error_msg[100];

void hello_message() {
  char hello_msg[80] = "Hello";
  errno_t e = strcpy_s(error_msg, 100, "Error");
  /* .. handle e - the value returned by strcpy_s */
}

When the block is small, the danger of reusing variable names is mitigated by the visibility of the immediate declaration. Even in this case, however, variable name reuse is not desirable.

...