guys,
I need to declare a pointer to a string. Which of the following is
better and why?
Depends what you really needs. Does it not matter if the chars in the
string are signed or not?
You would like to define that any char is definitely unsigned and you
don't trust that your environment makes char definitely unsigned,
except you tells it otherwise?
You have to be sure that any char in the string is signed?
signed char *pStr;
However I use a compiler option to have any string unsigned as default
- except I use 'signed' explicity. You will have to ask the
documentation of your compiler for the flag to define 'char' as 'be
always unsigned'. Typical usase of a char is unsigned for printout
(display on screen). Typical use for using char as short short
mathematical data type is 'signed char'. As the standard lets it
completely to the implementation to use signed or unsigned char when
'char' is used the behavior for 'char' is either 'signed char' or
'unsigned char' depending on the documentation of your compiler.
On other hand you compiler will have a flag (e.g. #pragma or a
commandline option) to set a specific behavior of (pointer to) 'char'.
At lest it is on you, the developer, to be sure to have a clearly
specified behavior of (un)singned behavior for the whole program and
use explicity 'signed' respective 'unsigned char' for cases you must
use the contrary to the (selected) default.
That
--
Tschau/Bye
Herbert
Visit
http://www.ecomstation.de the home of german eComStation
eComStation 1.2 Deutsch ist da!