c++ - strcpy() error in Visual studio 2012 - Stack Overflow.pdf

C++ - strcpy() error in Visual studio 2012 - Stack Overflow.pdf

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Tell me more × ГошУ 5,705 24 97 170 3 Answers so I have this code: #include "stdafx.h" #include <cstdlib> #include <iostream> #include <string> using namespace std ; ... char * b = new char [ 10 ]; strcpy ( b , "1234567890" ); error: microsoft visual studio 11.0\vc\include\string.h(110) : see declaration of 'strcpy' How do I fix it? c++ visual-studio-2012 asked Aug 30 '12 at 19:31 1 Visual Studio 2013? – Roman R. Aug 30 '12 at 19:33 2012, my mistake – ГошУ Aug 30 '12 at 19:34 Is that the full error message? Are you sure that there isn't more to it, perhaps complaining that you should avoid using strcpy ? – jamesdlin Aug 30 '12 at 19:35 3 error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. – ГошУ Aug 30 '12 at 19:36 10 The funny thing is that here, it is actually saving your butt because you copy 11 characters into a 10- character array. Really, use std::string instead. – chris Aug 30 '12 at 19:42 show 2 more comments There's an explanation and solution for this on MSDN:
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern