我得到一个程序,该标准使用字符串的值。 我如何更改它,以便用户可以输入值?字符串的用户输入
问候
Joriek
#include <iostream>
#include <string>
using namespace std;
int main()
{
std::string id_strnormal = "4a";
std::string code = "10 4a 00 11 22 33 44 55 66 77 88 99 10 03";
std::string start_str = code.substr(0, 2);
std::string id_str = code.substr(3, 2);
int str_length = code.length();
std::string stop_str = code.substr(str_length-5);
if (id_str == id_strnormal)
{
std::cout << code << std::endl;
}
if (id_str != id_strnormal)
{
std::cout << "package id isn't 4a" << std::endl;
}
system ("pause");
return 0;
}
难道你不打算在你的代码中添加'using namespace std;'的目的吗? ^^ – 2012-03-07 07:57:56
你可以采取任何基本的C++书籍,并通过阅读或谷歌找到答案!这是一个非常基本的问题 – 2012-03-07 08:02:02