Hi. I have one silly problem. I'm trying to read from file with ReadFile.read(ReadBuff, 1); char by char and i need to convert them to ascii code. With normal ascii symbols it's all right. But them i'm trying to convert extended ascii symobl to ascii code it gives me negative value. I'm using int ascii = int(ReadBuff); Any ideas?

Recommended Answers

All 6 Replies

Try using unsigned int...How is ReadBuff defined?

char m_ReadBuff;
char *p_ReadBuff = &m_ReadBuff;
ReadFile.read(p_ReadBuff, 1);
m_SymbolInt = int(m_ReadBuff);

Unsigned int isn't working too.

Yeah I would try

unsigned char m_ReadBuff;
unsigned char *p_ReadBuff = &m_ReadBuff;

std::basic_istream<_Elem,_Traits>::read' : cannot convert parameter 1 from 'unsigned char *' to 'char *'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Not working too

Try

ReadFile.read((char*)p_ReadBuff, 1);

It's working, thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.