Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. I would like to have your suggestion!

I would like to have your suggestion!

Scheduled Pinned Locked Moved C / C++ / MFC
help
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LaHaHa
    wrote on last edited by
    #1

    My program get a warning warning C4995: 'strcpy': name was marked as #pragma deprecated strcpy(buff,"#test.\r\n"); I should disable the warning or using other function! If using other function, which I should used. I would like to have your suggestion! Please help!

    S M P 3 Replies Last reply
    0
    • L LaHaHa

      My program get a warning warning C4995: 'strcpy': name was marked as #pragma deprecated strcpy(buff,"#test.\r\n"); I should disable the warning or using other function! If using other function, which I should used. I would like to have your suggestion! Please help!

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #2

      Unless you have a good reason to don't use any of the old CRT string functions. Instead use a string class such as MFC's CString or STL's std::string.

      Steve

      L 1 Reply Last reply
      0
      • S Stephen Hewitt

        Unless you have a good reason to don't use any of the old CRT string functions. Instead use a string class such as MFC's CString or STL's std::string.

        Steve

        L Offline
        L Offline
        LaHaHa
        wrote on last edited by
        #3

        The buff is char *. Could tell how to do this strcpy(buff, "#...") with simpliest method? Please help!

        S 1 Reply Last reply
        0
        • L LaHaHa

          The buff is char *. Could tell how to do this strcpy(buff, "#...") with simpliest method? Please help!

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #4

          Don't use char* at all (unless you have a compelling reason). If you're using MFC try using CString instead. e.g. CString MyString1 = "Hello"; CString MyString2 = "world"; CString MyString3 = MyString1 + " " + MyString2 + "."; CString MyString4 = MyString3; AfxMessageBox(MyString4); No explict buffers, no memory allocation, no buffer overruns and no worries.

          Steve

          L 1 Reply Last reply
          0
          • S Stephen Hewitt

            Don't use char* at all (unless you have a compelling reason). If you're using MFC try using CString instead. e.g. CString MyString1 = "Hello"; CString MyString2 = "world"; CString MyString3 = MyString1 + " " + MyString2 + "."; CString MyString4 = MyString3; AfxMessageBox(MyString4); No explict buffers, no memory allocation, no buffer overruns and no worries.

            Steve

            L Offline
            L Offline
            LaHaHa
            wrote on last edited by
            #5

            Thank you very much! It's alright now!

            1 Reply Last reply
            0
            • L LaHaHa

              My program get a warning warning C4995: 'strcpy': name was marked as #pragma deprecated strcpy(buff,"#test.\r\n"); I should disable the warning or using other function! If using other function, which I should used. I would like to have your suggestion! Please help!

              M Offline
              M Offline
              Mike ONeill
              wrote on last edited by
              #6

              In direct answer to your question, to disable the warning and (automatically) to use another function, then include this line in your code: #define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1 This will automatically substitute secure versions of CRT functions, e.g., it will substitute the secure version strcpy_s for its unsecure counterpart strcpy. The benefit is that you do not need to make any changes to your existing code. See "Secure Template Overloads" at http://msdn2.microsoft.com/en-us/library/ms175759(VS.80).aspx[^]. To read more about secure vs. non-secure CRT functions, see "Security Enhancements in the CRT" at http://msdn2.microsoft.com/en-us/library/8ef0s5kh(VS.80).aspx[^]. Mike

              L 1 Reply Last reply
              0
              • M Mike ONeill

                In direct answer to your question, to disable the warning and (automatically) to use another function, then include this line in your code: #define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1 This will automatically substitute secure versions of CRT functions, e.g., it will substitute the secure version strcpy_s for its unsecure counterpart strcpy. The benefit is that you do not need to make any changes to your existing code. See "Secure Template Overloads" at http://msdn2.microsoft.com/en-us/library/ms175759(VS.80).aspx[^]. To read more about secure vs. non-secure CRT functions, see "Security Enhancements in the CRT" at http://msdn2.microsoft.com/en-us/library/8ef0s5kh(VS.80).aspx[^]. Mike

                L Offline
                L Offline
                LaHaHa
                wrote on last edited by
                #7

                Thank you very much!

                1 Reply Last reply
                0
                • L LaHaHa

                  My program get a warning warning C4995: 'strcpy': name was marked as #pragma deprecated strcpy(buff,"#test.\r\n"); I should disable the warning or using other function! If using other function, which I should used. I would like to have your suggestion! Please help!

                  P Offline
                  P Offline
                  prasad_som
                  wrote on last edited by
                  #8

                  If you want to go with CRT functions, you can go its secure version strcpy_s. Refer this[^] for more information. [Edit] This link is already provided in Mike's reply [Edit]

                  Prasad Notifier using ATL | Operator new[],delete[][^]

                  L 1 Reply Last reply
                  0
                  • P prasad_som

                    If you want to go with CRT functions, you can go its secure version strcpy_s. Refer this[^] for more information. [Edit] This link is already provided in Mike's reply [Edit]

                    Prasad Notifier using ATL | Operator new[],delete[][^]

                    L Offline
                    L Offline
                    LaHaHa
                    wrote on last edited by
                    #9

                    Thank you very much!

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups