C & C++

C & C++

Made by DeepSource

Found unnecessary conversion from std::string to C-style string CXX-C2024

Style
Minor
Autofix

Found conversion of a std::string to a C-style string using the c_str() or `data() methods. This is unnecessary and can lead to potential memory issues while also being less efficient.

To fix this issue, use std::string directly without converting it to a C-style string.

Bad practice

std::string foo(std::string str);

void bar(void {
  std::string pass;
  foo(pass.c_str());
  foo(pass.data());
}

Recommended

std::string foo(std::string str);

void bar(void {
  std::string pass;
  foo(pass);
  foo(pass);
}