How to get rid of “unsafe” warnings / errors in Visual Studio (strcpy, sprintf, strdup)

后端 未结 9 1515
臣服心动
臣服心动 2020-12-05 10:43

I\'m trying to get rid of some compiler warnings that say strcpy, sprintf, etc are unsafe. I get why they\'re unsafe, but I can\'t think of a good way to fix the code, in a

9条回答
  •  青春惊慌失措
    2020-12-05 11:10

    Here is another answer to this question.

    #ifdef _MSC_VER
    #pragma warning(push)
    #pragma warning(disable : 4996)
    #endif
    
            strcpy(destination, source);
    
    #ifdef _MSC_VER
    #pragma warning(pop)
    #endif
    

提交回复
热议问题