user3195332
user3195332

Reputation: 13

error C3861: 'strcpy_y': identifier not found

Pacient& operator = ( Pacient&p) {
  cout << "Operator = Pacient" << endl;
  delete [] this->nume;
  this->nume = new char[strlen(p.nume)+1];
  strcpy_y(this->nume,strlen(p.nume)+1,p.nume); // ERROR
  delete [] this->prenume;
  this->prenume = new char[strlen(p.prenume)+1];
  strcpy_y(this->prenume,strlen(p.prenume)+1,p.prenume); // ERROR
  this->varsta = p.varsta;
  return *this;
}

1>Compiling...
1>pacienti.cpp
1>f:\bob\facultate\semestrul iii\programareorientataobiect\proiect pacienti\proiect\proiect\pacienti.cpp(24) : error C3861: 'strcpy_y': identifier not found
1>f:\bob\facultate\semestrul iii\programareorientataobiect\proiect pacienti\proiect\proiect\pacienti.cpp(27) : error C3861: 'strcpy_y': identifier not found

I get this error. Why? What should I do to get rid of it?

Upvotes: 0

Views: 1301

Answers (3)

John Dibling
John Dibling

Reputation: 101456

There's no such thing as strcpy_y, at least not in Standard C++.

Perhaps you meant strcpy_s from WINAPI?

If strcpy_y is a function you have created yourself, then you need to #include the file where it is declared.

Why use raw C-style strings in the first place? Just use std::string allocated as a locat variable and all these problems go away. Use operator= to copy the strings.

Upvotes: 2

Yudaev Alexander
Yudaev Alexander

Reputation: 36

I think that it can be help you: #include <string.h>

But I don't recommended use strcpy_y in your code, because it's not C++.

Upvotes: 0

JBentley
JBentley

Reputation: 6260

The compiler doesn't know what strcpy_y is because you haven't declared it anywhere prior to that line in the current translation unit.

Either provide the declaration for strcpy_y (e.g. #include a relevant header, or forward declare it), or fix the typo if you meant to call some other function.

Upvotes: 2

Related Questions