本文介绍了什么功能可以代替“strcpy”代替?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在visual studio 2012中得到这样的错误:

错误C4996:'strcpy':此函数或变量可能不安全。请考虑使用strcpy_s。要禁用弃用,请使用_CRT_SECURE_NO_WARNINGS



也可以在char * cPtr = strtok(cStr,);











get error like this in visual studio 2012:
error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS

also get this in "char *cPtr = strtok (cStr, " ");"





void parser(string line, int fileNo, class HashTable & HT, frequencyList FL[])
{
        // Variables declarations
        //char * cStr, * cPtr;
        string tempString;



        char* cStr=new char[line.length()+1];
        strcpy(cStr ,line.c_str());

        /*
        // Define cStr = the size of line + 1
        // Copy the string line to char * cStr
        cStr = new char [line.size() + 1];
        strcpy (cStr, line.c_str());
        */
        // Parese cStr by " "
        char *cPtr = strtok (cStr, " ");
        while (cPtr != NULL)
        {
                if (strcmp(cPtr, "</TEXT>") != 0 && *cPtr != '.')
                {
                        tempString = string(cPtr);

                        // Call removeCommaBehind function to remove , behind word
                        removeCommaBehind(tempString);



                        if(tempString.compare(",") != 0)
                        if(tempString.compare(".") != 0)
                        if(tempString.compare("=") != 0)
                        {
                                // Call countFrequency() function
                                countFrequency(tempString, FL);
                        }
                }
                cPtr = strtok(NULL, "()/ ");
        }
        delete[] cStr;
}

推荐答案




这篇关于什么功能可以代替“strcpy”代替?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-11 21:27