hi!
how do I call UCHAR_MIN & UCHAR_MAX ?
printf("unsigned-char: [%c, %c]\n", UCHAR_MIN, UCHAR_MAX);
Iam getting error with %c? with one I should use? and why?
thax in advance
--
______________________________________
I se the lightat the end, but every time I take a step it's get dim. 9 5568
Carramba wrote on 30/01/05 : how do I call UCHAR_MIN & UCHAR_MAX ? printf("unsigned-char: [%c, %c]\n", UCHAR_MIN, UCHAR_MAX); Iam getting error with %c? with one I should use? and why?
What error ?
First of all, try with "%d" to see the values (in decimal).
BTW, I guess you included <limits.h>
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html
"C is a sharp tool"
yes,
the problem was there isn't UCHAR_MIN .... only MAX ...
thanx
On Sun, 30 Jan 2005 16:56:57 +0100, Emmanuel Delahaye
<em***@YOURBRAnoos.fr> wrote: Carramba wrote on 30/01/05 : how do I call UCHAR_MIN & UCHAR_MAX ? printf("unsigned-char: [%c, %c]\n", UCHAR_MIN, UCHAR_MAX); Iam getting error with %c? with one I should use? and why?
What error ?
First of all, try with "%d" to see the values (in decimal).
BTW, I guess you included <limits.h>
--
______________________________________
I se the lightat the end, but every time I take a step it's get dim.
Carramba <no****@privet.net> wrote: how do I call UCHAR_MIN & UCHAR_MAX ?
^^^^^^^^^
What this? -------^
printf("unsigned-char: [%c, %c]\n", UCHAR_MIN, UCHAR_MAX); Iam getting error with %c? with one I should use? and why?
What's the error message?
--
Stan Tobias
mailx `echo si***@FamOuS.BedBuG.pAlS.INVALID | sed s/[[:upper:]]//g`
Carramba wrote: how do I call UCHAR_MIN & UCHAR_MAX ? printf("unsigned-char: [%c, %c]\n", UCHAR_MIN, UCHAR_MAX); Iam getting error with %c? with one I should use? and why?
First you need to #include <limits.h>. Then you need to use %d,
since those macros describe the limits of the type, and those
limits are not necessarily printable. Third, there is no
UCHAR_MIN, it is zero, as for all unsigned types.
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Carramba wrote on 30/01/05 : yes,
the problem was there isn't UCHAR_MIN .... only MAX ...
thanx
On Sun, 30 Jan 2005 16:56:57 +0100, Emmanuel Delahaye <em***@YOURBRAnoos.fr> wrote:
Carramba wrote on 30/01/05 : how do I call UCHAR_MIN & UCHAR_MAX ? printf("unsigned-char: [%c, %c]\n", UCHAR_MIN, UCHAR_MAX); Iam getting error with %c? with one I should use? and why?
What error ?
First of all, try with "%d" to see the values (in decimal).
BTW, I guess you included <limits.h>
After brain shaking...
UCHAR_MIN doesn't exist. It's 0 by definition.
BTW, the correct formatter is "%u".
printf("unsigned-char: [%c, %c]\n", 0, UCHAR_MAX);
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html
"Mal nommer les choses c'est ajouter du malheur au
monde." -- Albert Camus.
Emmanuel Delahaye <em***@yourbranoos.fr> wrote: BTW, the correct formatter is "%u".
printf("unsigned-char: [%c, %c]\n", 0, UCHAR_MAX);
Didn't you mean to write:
printf("unsigned-char: [%u, %u]\n", 0, UCHAR_MAX);
?
UCHAR_MAX constant is promoted to either singed or unsigned int.
Since the value is positive, either result must have the same
representation. The difference is only in the type. Is a cast
before the constants recommended or not in this case?
--
Stan Tobias
mailx `echo si***@FamOuS.BedBuG.pAlS.INVALID | sed s/[[:upper:]]//g`
S.Tobias <si***@famous.bedbug.pals.invalid> wrote: UCHAR_MAX constant is promoted to either singed or unsigned int.
XXXXXXXXXXXXXX
UCHAR_MAX _is_ either singed or unsigned int (depending on the result
of the promotion of unsigned char - cf. 5.2.4.2.1).
--
Stan Tobias
mailx `echo si***@FamOuS.BedBuG.pAlS.INVALID | sed s/[[:upper:]]//g`
S.Tobias wrote on 31/01/05 : Emmanuel Delahaye <em***@yourbranoos.fr> wrote:
BTW, the correct formatter is "%u".
printf("unsigned-char: [%c, %c]\n", 0, UCHAR_MAX);
Didn't you mean to write: printf("unsigned-char: [%u, %u]\n", 0, UCHAR_MAX); ?
Sure!
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html
"Mal nommer les choses c'est ajouter du malheur au
monde." -- Albert Camus.
Emmanuel Delahaye wrote: S.Tobias wrote on 31/01/05 : Emmanuel Delahaye <em***@yourbranoos.fr> wrote:
BTW, the correct formatter is "%u".
printf("unsigned-char: [%c, %c]\n", 0, UCHAR_MAX);
Didn't you mean to write: printf("unsigned-char: [%u, %u]\n", 0, UCHAR_MAX); ?
Sure!
%u expects an unsigned int, not an int. The wording of the
standard doesn't guarantee that %u will work in this case
(although that _was_ the intent of the committee.)
That said, it is arguable whether a hosted implementation
can be considered conforming if UCHAR_MAX promotes to
unsigned int, so I think that...
printf("unsigned-char: [%d..%d]\n", 0, UCHAR_MAX);
....is safer. If you're truly paranoid, then use...
printf("unsigned-char: [%u..%u]\n", 0u, 0u + UCHAR_MAX);
--
Peter This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mark Shelor |
last post by:
I've encountered a troublesome inconsistency in the C-language Perl
extension I've written for CPAN (Digest::SHA). The problem involves the
use of a static array within a performance-critical...
|
by: Prem Mallappa |
last post by:
Hi everyone
this is the program given in answer book to K&R
====================================
#include <stdio.h>
int main()
{
printf (" signed char = %d", -(char) ((unsigned char) ~0 >>...
|
by: DanielJohnson |
last post by:
I am reading K&R and right now in section 2.9 bitwise operators. I
understood most of the simple things initially but getting stuck with
the later part where different functions like getbits(),...
|
by: arnuld |
last post by:
as i said, i have restarted the book because i overlooked some
material. i want to have some comments/views on this solution. it runs
fine, BTW.
------------------ PROGRAMME --------------
/*...
|
by: Christopher Benson-Manica |
last post by:
In a thread from substantially earlier this week,
Harald van D?k <truedfx@gmail.comwrote:
Being rather pendantic, I decided to try to verify whether this was
true. I would appreciate...
|
by: Kislay |
last post by:
Consider the following code snippet
unsigned int i=10;
int j= - 2; // minus 2
if(i>j)
cout<<"i is greater";
else
cout<<"j is greater";
Since i is unsigned , j is greater . I know why , but...
|
by: Jorge Peixoto |
last post by:
In the answer to question 12.42 of the C FAQ, we have this code:
putc((unsigned)((s.i32 >24) & 0xff), fp);
putc((unsigned)((s.i32 >16) & 0xff), fp);
putc((unsigned)((s.i32 >8) & 0xff), fp);...
|
by: santosh |
last post by:
Hello all,
In K&R2 one exercise asks the reader to compute and print the limits for
the basic integer types. This is trivial for unsigned types. But is it
possible for signed types without...
|
by: Zach |
last post by:
I recall someone posting a website that had the complete K&R (2nd Ed.
- ANSI) answers posted but I cannot find the post.
Zach
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |