^_^ said:
I'm sorry that I was rude to speak unpolite broken English.
It's my fault. I am not an English speaker
That's OK, it wasn't rude, nor was your English unpolite in any way. (By
the way, the normal English word is "impolite." "Unpolite" is perfectly
logical and understandable, but it disappeared from normal English use in
the early 18th century.) The problem is that you didn't give us a question
that we could understand. Many people who *are* native English speakers
fail to do this.
Posting to both C and C++ newsgroups is likely an error. C and C++ are
different languages, and, even when the languages admit the same forms of
code, the normal idioms in the two languages are different. It makes sense
to post to both _only_ when the question has the same answers in both
languages. Since you can't know this, since you would then already know
the answer, it is best to post to a newsgroup for the language you are using.
Though, I can speak more correct expression, I was neglect.
As a side note, you might consider comp.usage.english as another newsgroup
you might post in, if improving your English is important to you. The
above line, for example, might more idiomatically be written, "However, I
can express myself better. I was negligent [or neglectful]."
What I want is to convert Unicode characters in source code to 0x???
format.
If you can read the Unicode characters into a buffer, you can convert those
chars into an integer, as long as the total number of bytes in a character
is less than the sizeof the integer (best unsigned) type that you use.
I want to know, either, that convert decimal format numbers to hexademical
format.
Numbers as stored are simply binary, interpreted for humans as in some base.
Suppse you have an unsigned int
unsigned int a = 263;
We can display this as octal
printf("%#o\n",a); /* displays 0407 */
or hex
printf("%#x\n",a); /* displays 0x107 */
or decimal
printf("%u\n",a); /* displays 263 */
For example, I'll show an source.
example.cpp:
#define MAX 16777215
void main(){
main always returns an int. "void" is wrong. Don't do this.
if (MAX==a) printf("wrong\n"
;
Even though this is an example of an input file, it is best not to post
hopeless code.
The variable 'a' is undeclared.
The C++ people may object that "printf" is too un-C++-like and complain
that <cstdio> is not #included.
The C people might complain that <stdio.h> is not #included. People
using compilers without C99 conformance (almost all), may complain
that main should actually return a value; 0 is common for successful
completion and EXIT_SUCCESS and EXIT_FAILURE are available if
}
example_I_wanted.cpp
#define MAX 0xFFFFFF <------*this part*
void main(){
main always returns an int. "void" is wrong. Don't do this.
if (MAX==a) printf("wrong\n"
;
}
To do so, C or C++ source parsing->converting DEC to HEX->saving CPP file
with converted characters are needed.
To parse an input file containing a C program is probably beyond you at the
moment. You will need to detect sequence of characters that might be an
integer, determine that it is one (this requires examining its context),
and probably checking the use for signedness.
It is probably better for you to edit these files by hand. It is largely
because of the occurances "void main()" that I presume that your computing
skills are not up to writing such a program. If I am in error, I apologize.