c++ 字符数组-print and 写入文件
1.print
char buffer[22][8] = { 0 }; method1: 为了打印出unsigned char数据所对应的数值,可以将其强制转换成int类型,并做打印输出。 std::cout << "buffer[22][0]: " << std::hex << (int)buffer[22][0] << std::endl; method2: printf("buffer[0]: --- %x --- %d\n", (unsigned char)buffer[i][0], i+1);
2. write into file..
//#include <fstream> std::ofstream in;//buffer data to be writen... std::ofstream out;//can data... in.open("in.txt", ios::trunc); out.open("out.txt", ios::trunc); for (int k = 0; k < 8; k++) { out << std::hex << (int)frame.data[k] << "\t"; } out << "\n"; //close file. in.close(); out.close();
RE:
1.https://blog.csdn.net/u012273127/article/details/53260156;
END
各美其美,美美与共,不和他人作比较,不对他人有期待,不批判他人,不钻牛角尖。
心正意诚,做自己该做的事情,做自己喜欢做的事情,安静做一枚有思想的技术媛。
版权声明,转载请注明出处:https://www.cnblogs.com/happyamyhope/
心正意诚,做自己该做的事情,做自己喜欢做的事情,安静做一枚有思想的技术媛。
版权声明,转载请注明出处:https://www.cnblogs.com/happyamyhope/