-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstd_sstream.cpp
65 lines (51 loc) · 1.3 KB
/
std_sstream.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* =====================================================================================
*
* Filename: sstream.cpp
*
* Description:
*
* Version: 1.0
* Created: 2015年04月06日 14时41分38秒
* Revision: none
* Compiler: gcc
*
* Author: zt (),
* Organization:
*
* =====================================================================================
*/
#include <string>
#include <sstream>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <iomanip>
using namespace std;
int main ( int argc, char* argv[] )
{
( void ) argc;
( void ) argv;
uint8_t temp[42] = { 0x1, 0x2, 0x3, 0x5, 0x99};
uint8_t pDmdHsg[42] = { 0x11, 0x3, 0x3, 0x5, 0x99};
auto f = [&] ( uint8_t* p1, uint8_t* p2, int num )
{
for ( int i = 1; i < num; i += 2 )
if ( p1[i] != p2[i] )
return false;
return true;
};
cout << f ( temp, pDmdHsg, 42 ) << endl;
#if 0
stringstream sx, sd;
for ( int j = 0; j < 42; ++j )
{
sx << "0x" << std::hex << std::setw ( 2 ) << std::setfill ( '0' ) << ( int ) temp[j] << " ";
sd << "0x" << std::hex << std::setw ( 2 ) << std::setfill ( '0' ) << ( int ) pDmdHsg[j] << " ";
}
cout << sx.str() << endl;
cout << sd.str() << endl;
#endif
return 0;
}