我想读取midi文件的单个字节,我写了一个简单的程序来尝试这样做:
ifstream file{"D:\Descargas\OutFile.midi" };
if (!file.is_open())
cout << "Not open" << endl; // It passes this test
char c;
for (unsigned i = 0; i < 100; ++i) {
file >> c;
cout << c << endl; // Output is -52, but it must output 4D which is 77 in decimal
}
但正如我写的那样,输出效果并不好,我也不知道自己哪里出错了。
答案 0 :(得分:0)
您需要将输出配置为以十六进制打印,并使用JSONArray people = new JSONArray(jsondata);
int index = 0;
for (int i = 0; i < people.length(); i++) {
JSONObject tmpObj = people.getJSONObject(i);
string name = tmpObj.getString("full_name");
if (name == "John") {
index = i;
break;
}
}
JSONObject johnObjExample = people.getJSONObject(index);
string johnName = johnObjExample.getString("full_name");
int id = johnObjExample.getInt("id");
String name = johnObjExample.getString("full_name");
String sex = johnObjExample.getString("sex");
String location = johnObjExample.getString("location");
将每个数字填充到宽度0
。此外,您需要将字符2
强制转换为c
,以便它不会以字母形式输出:
int
答案 1 :(得分:0)
实际上必须转义\
字符。