Expression:(L"Buffer is too small" &&0) error from strcpy_s() function

  • Thread starter Thread starter Jeff0803
  • Start date Start date
J

Jeff0803

Guest
That error occur from

#include <iostream>
using namespace std;

class String
{
private:
char* s;
int size;
public:
String(char*); // constructor
~String(); // destructor
};

String::String(char* c)
{
size = strlen(c);
s = new char[size + 1];
strcpy_s(s, size, c);
}

String::~String()
{
delete[]s;
}

int main()
{
char array[] = "Hello world";
String *s = new String(array);
delete[] array;
return 0;
}

Can anybody make it work?

Continue reading...
 
Back
Top