0

I need to convert array of char to hex one char at a time ,
I tried to use sprintf,but it did not work.

?

2
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by ekailan
0

Are you trying to display the character's value as a hexadecimal?

#include <iostream>

int main()
{
  unsigned char myc = 'o';
  
  std::cout << (int)myc << std::endl;
  std::cout << std::hex << (int)myc << std::endl;
  std::cout << std::oct << (int)myc << std::endl;
  
  return 0;
}

Edited by gerard4143: n/a

0

actully no , I put the cout<< to test the code , I need to calculate the number of string in all files that is of length 1 , 2,......,50,then write the result to another file


the problem is that every thing is working 100% for the first file only

Edited by ekailan: n/a

0

Sorry I posted tow thread togother I thought you are talking about the other one, anyway thank you for your answer

Edited by ekailan: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.