I was just wondering if treating an extern variable as the source buffer and passing it as an argument to strcpy() or any other function that can result in a buffer overflow is as unsafe and likely to result in buffer overflows as passing it an argument that came from an fgets() function with a specified limit higher than the size of the buffer.
Should special care be used with these extern variables or should they be treated no differently than any other variable?
externonly defines the linkage of an variable it does not change the variable in any other way.It is as safe/Unsafe as any other variable, the variable being declared
externhas no bearing.Using
strcpyis as such Unsafe and may cause buffer overflows.In C++ better option is to use
std::string