How can I replace strcpy without losing performance?

for (i = 0; i < kol; i++) if ((strcmp(Regname.Name, mas[i].Name) == 0) && (strcmp(Regname.Password, mas[i].Password) == 0)) { strcpy(role, mas[i].role); delete[]mas; return Regname.Name; } 

This question has appeared, because constantly getting an error about an insecure function or variable.

Error C4996. To solve it define define _CRT_SECURE_NO_WARNINGS is not an option.

I would like to hear the answer for the modern level, if the strcpy is "obsolete".

Replacing strcpy_s causes other errors:

  • There are no instances of the overloaded function "strcpy_s" function corresponding to the argument list.

  • strcpy_s: the function does not accept 2 arguments

If you write 3 arguments, as it should be, it displays an error: cry

  • 2
    Хотелось бы услышать ответ для современного уровня - can use std::string - diraria
  • If for some reason it is necessary to work with C-style arrays, pass the arguments as required by strcpy_s . - VTT
  • @VTT yes, I know that 3 parameters are required. After compiling and running the program displays this: imgur.com/ptS5xg1 - Thomas MacCort
  • Use strncpy() - Fat-Zer
  • one
    Well? Your error has nothing to do with strcpy or strcpy_s . What does she have to do with it? - AnT

0