César Pereira César Pereira - 1 year ago 89
C++ Question

How can i overcome "unsafe" error?

I'm working on a project that is basically controlling a parking lot. And in some point of my code I use the function

strcpy()
, but I am getting an error saying that this function may be unsafe.

Here's the part of the code I'm using
strcpy()
:

Automovel::Automovel(char * matr, Data ent, double comp) {
//CONSTRUTOR POR ENUMERAÇAO:
//RECEBE A MATRICULA, A DATA DE ENTRADA E O COMPRIMENTO DO CARRO
//POSIÇAO E VALOR PAGO FICA INDEFINIDO
matricula = new char[11];
entry = new Data(ent);

strcpy(matricula, matr);
comprimento = comp;
pos[0] = -1; pos[1] = -1;
pago = -1;
}


I need to use the function, so, how can I solve this error?

Answer Source

Your issue is that strcpy is an 'unsafe' function so you need to disable the unsafe warning in Visual Studio so follow these steps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download