Почему? объясните с максимальной подробностью.
#include <iostream>
#include <string>
void parseAnswerFromCOM(const std::string& source)
{
std::string::size_type first = 0;
std::string::size_type last = 0;
while((last = source.find(';', first)) != std::string::npos)
{
std::string r = source.substr(first, last - first);
std::cout << r << "\n";
first = last + 1;
}
}
int main()
{
std::string s = "asdf;ghjkl;vbnhg;poiuy;";
parseAnswerFromCOM(s);
std::cin.get();
}
When you use the C-style string functions with Microsoft Visual
Studio, the compiler is likely to give you security-related warnings or even
errors about these functions being deprecated. You can eliminate these warnings
by using other C Standard Library functions, such as strcpy_s() or
strcat_s(), which are part of the “secure C library” standard (ISO/IEC TR
24731). However, the best solution is to switch to the C++ Standard Library
std::string class.
все равно не работает.
#include <filesystem>
#include <iostream>
using namespace std;
namespace fs = experimental::filesystem;
void main()
{
cout << fs::current_path().string() << endl;
system("pause");
}
string s = "string = '";
s += result;
s += "'.split(';')[0]\nprint(string, end='')";
code_normalization(s);
Негативный опыт у меня следующий: на кожаном жарко; без подлокотников неудобно; спинка у большинства кресел, через какое-то время начинает люфтить, и сидишь на нем уже не прямо, а с наклоном назад; плюс еще мелочи вроде откатывания назад.
ОШИБКА ДОЛЖНА БЫТЬ ГДЕ-ТО ТУТ :
по ссылке указатель на указатель на char
#include <iostream>
#include <cstring>
auto doit(char** &ptr)
{
ptr = new char*[2];
ptr[0] = new char[2];
ptr[1] = new char[2];
memcpy(ptr[0], "Y\0", 2);
memcpy(ptr[1], "N\0", 2);
return 2;
}
int main()
{
char** ptr = nullptr;
int sz = doit(ptr);
for(int i = 0; i < sz; ++i)
{
std::cout << ptr[i] << "\n";
}
for(int i = 0; i < sz; ++i)
{
delete ptr[i];
}
delete ptr;
}
И я осознанно не хочу использовать векторы, так как хочу сделать все на максимально низком уровне.
https://stackoverflow.com/questions/34762865/compa...