shamuntoha
Programmer
How to get the output 0X33 not 0X334 ? (gcc compiler)
code:
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
int arr[256] = {1,0x23,0x6C,0x1,0x2};
string leg1 = "324856789";
int leg2 = leg1.length();
for (int i=5; i < leg2+5; i ++ ) {
arr = printf("%#X",leg1[i-5]);
cout << arr << "\n";
}
system(PAUSE);
return 0;
}
code:
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
int arr[256] = {1,0x23,0x6C,0x1,0x2};
string leg1 = "324856789";
int leg2 = leg1.length();
for (int i=5; i < leg2+5; i ++ ) {
arr = printf("%#X",leg1[i-5]);
cout << arr << "\n";
}
system(PAUSE);
return 0;
}