473,386 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

printf("%d",float)

Hi all,
I just came across the following program:

#include <stdio.h>
int main()
{
float a = 12.5;
printf("%d\n", a);
printf("%d\n", *(int *)&a);
return 0;
}

The program prints 0 and 1095237362. However, in my opinion it should
print 12 at both the places. Can anybody tell me where I am wrong?

Oct 31 '07 #1
29 11034
ca********@yahoo.com said:
Hi all,
I just came across the following program:

#include <stdio.h>
int main()
{
float a = 12.5;
printf("%d\n", a);
printf("%d\n", *(int *)&a);
return 0;
}

The program prints 0 and 1095237362. However, in my opinion it should
print 12 at both the places. Can anybody tell me where I am wrong?
You are wrong in thinking that %d is the appropriate format specifier for a
float, and you are wrong in thinking that you can meaningfully cast the
address of a float into the address of an int.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Oct 31 '07 #2
ca********@yahoo.com wrote:
Hi all,
I just came across the following program:

#include <stdio.h>
int main()
{
float a = 12.5;
printf("%d\n", a);
printf expects and treats the corresponding argument as a signed int,
while you've passed it a float value.
printf("%d\n", *(int *)&a);
Same as above and an additional problem:

Pointers values of different types need not be compatible in C, except
that a conversion of any pointer to void * and back again shall be
okay.
return 0;
}

The program prints 0 and 1095237362. However, in my opinion it should
print 12 at both the places. Can anybody tell me where I am wrong?
Yes. You've written an incorrect program, so incorrect results are to be
expected.

Read:

<http://www.c-faq.com/>

Oct 31 '07 #3
On Oct 30, 8:48 pm, candy_i...@yahoo.com wrote:
Hi all,
I just came across the following program:

#include <stdio.h>
int main()
{
float a = 12.5;
printf("%d\n", a);
printf("%d\n", *(int *)&a);
return 0;
}

The program prints 0 and 1095237362. However, in my opinion it should
print 12 at both the places. Can anybody tell me where I am wrong?
Pointer casting does not convert values of one type to another. Your
code is sort of like this:
struct {
char a;
} A ;
struct {
float b;
} B;
printf("%c", ((A*)&B)->a);
OR
printf("%f", ((B*)&A)->a);
The latter will segfault/crash.
If sizeof(int) != sizeof(float) your code would have *very* likely
crashed. This is one of the reasons why you should be *very* careful
with pointers and never do anything fancy when working with pointers
UNLESS YOU COMPLETELY KNOW WHAT IT DOES, WHY IT DOES THAT, AND ANY
SIDE-EFFECTS. Be very careful, *especially* when you need to pass
void* arguments and struct-cast the pointer to get the data.

Getting back to the different number,
float = [sign bit] [7 exponent bits] [23 mantissa bits]
12.5 = 0 10000010 10010000000000000000000
= 0x41480000
= 1095237632
That's where your number came from.
Source: http://en.wikipedia.org/wiki/Single_precision

Oct 31 '07 #4
On 10 31 , 8 48 , candy_i...@yahoo.com wrote:
Hi all,
I just came across the following program:

#include <stdio.h>
int main()
{
float a = 12.5;
printf("%d\n", a);
printf("%d\n", *(int *)&a);
return 0;
}

The program prints 0 and 1095237362. However, in my opinion it should
print 12 at both the places. Can anybody tell me where I am wrong?
hi, I help this test program will help you!

#include <stdarg.h>
#include <stdio.h>

// printf's action is like this
void test(char *fmt, ...)
{
int i;
float j;

va_list ap, app;

va_start(ap, fmt);
app = ap;

i = va_arg(ap, int); // when you call like printf("%d\n", i);
this line while be called

j = va_arg(app, double); // when you call like printf("%f\n", i);
this line while be called
// and you can't call it like j = va_arg(app,
float), because gcc compiler will complain

va_end(ap);

printf("if the args interpret as int, you get %d\n", i);
printf("it should interpret as double, the right answer is %f\n",
j);
}

int main(void)
{
float a = 12.5;

test("%d", a);

return 0;
}
below is define of va_arg, you can find it in <stdarg.h>

typedef char * va_list;

#define va_start _crt_va_start
+-- #define va_arg _crt_va_arg
| #define va_end _crt_va_end
|
| #define _crt_va_start(ap,v) ( ap = (va_list)_ADDRESSOF(v) +
_INTSIZEOF(v) )
+-#define _crt_va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) -
_INTSIZEOF(t)) )
#define _crt_va_end(ap) ( ap = (va_list)0 )

Oct 31 '07 #5
santosh <sa*********@gmail.comwrites:
ca********@yahoo.com wrote:
>I just came across the following program:

#include <stdio.h>
int main()
{
float a = 12.5;
printf("%d\n", a);

printf expects and treats the corresponding argument as a signed int,
while you've passed it a float value.
> printf("%d\n", *(int *)&a);

Same as above and an additional problem:
[...]

Not quite. The argument is of type int, so "%d" is the correct
format. The problem, of course, is that obtaining the value of that
argument (evaluating ``*(int *)&a'') invokes undefined behavior.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Oct 31 '07 #6
On Wed, 31 Oct 2007 01:15:33 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote in comp.lang.c:
ca********@yahoo.com said:
Hi all,
I just came across the following program:

#include <stdio.h>
int main()
{
float a = 12.5;
printf("%d\n", a);
printf("%d\n", *(int *)&a);
return 0;
}

The program prints 0 and 1095237362. However, in my opinion it should
print 12 at both the places. Can anybody tell me where I am wrong?

You are wrong in thinking that %d is the appropriate format specifier for a
float, and you are wrong in thinking that you can meaningfully cast the
address of a float into the address of an int.
You were right in the first pronouncement, not necessarily so in the
second. The result of casting a pointer to an object or incomplete to
a pointer to any other object or incomplete type, is undefined if the
pointer is not suitably aligned for the second type, but well defined
if there is no alignment error. Of course, dereferencing that pointer
is completely undefined.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
Oct 31 '07 #7
Jack Klein said:
On Wed, 31 Oct 2007 01:15:33 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote in comp.lang.c:
<snip>
>>
You are wrong in thinking that %d is the appropriate format specifier
for a float, and you are wrong in thinking that you can meaningfully
cast the address of a float into the address of an int.

You were right in the first pronouncement, not necessarily so in the
second. The result of casting a pointer to an object or incomplete to
a pointer to any other object or incomplete type, is undefined if the
pointer is not suitably aligned for the second type, but well defined
if there is no alignment error. Of course, dereferencing that pointer
is completely undefined.
Right, which is why I consider the conversion meaningless.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Oct 31 '07 #8
andreyvul <andrey....@gmail.comwrote:
Pointer casting does not convert values of one type
to another.
Yes it does. Indeed, all conversions do precisely that.
Casting a pointer from one type to another converts the
pointer value from the original pointer type to a pointer
value of the cast type. Only certain conversions (and
chains thereof) are guaranteed to be lossless.

What you meant to say is that converting pointers does
not convert the value of the object being pointed to,
if any.

--
Peter

Oct 31 '07 #9
Richard Heathfield wrote:
Jack Klein said:
>On Wed, 31 Oct 2007 01:15:33 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote in comp.lang.c:
<snip>
>>You are wrong in thinking that %d is the appropriate format specifier
for a float, and you are wrong in thinking that you can meaningfully
cast the address of a float into the address of an int.
You were right in the first pronouncement, not necessarily so in the
second. The result of casting a pointer to an object or incomplete to
a pointer to any other object or incomplete type, is undefined if the
pointer is not suitably aligned for the second type, but well defined
if there is no alignment error. Of course, dereferencing that pointer
is completely undefined.

Right, which is why I consider the conversion meaningless.
So conversion to void * is always meaningless, because no void * can be
dereferenced?

Phil

--
Philip Potter pgp <atdoc.ic.ac.uk
Oct 31 '07 #10
ca********@yahoo.com wrote:
Hi all,
I just came across the following program:

#include <stdio.h>
int main()
{
float a = 12.5;
printf("%d\n", a);
This line is wrong because printf() expects an int but a is a float.
Note that because this is undefined behaviour (UB), this may cause a
crash on some C compilers - and even worse behaviour on others.

<OT>
To think about one reason this may crash on a machine with a stack, if
sizeof(float) != sizeof(int) then printf() will remove the wrong number
of bytes from the call stack, leaving the stack in an inconsistent state
after the call to printf().

A C compiler doesn't /need/ a reason like this to fail, however; if the
behaviour is undefined, it can do anything it likes for no reason at all.
</OT>
printf("%d\n", *(int *)&a);
I'm curious. Why did you write this instead of the correct (and simpler):

printf("%d\n", (int)a);

This converts the float value to an int value.

Your version takes the address of a to produce a 'float *', converts
that pointer to an 'int *', and dereferences that pointer. Converting a
float pointer to an int pointer isn't very meaningful.

--
Philip Potter pgp <atdoc.ic.ac.uk
Oct 31 '07 #11
Philip Potter said:
Richard Heathfield wrote:
>Jack Klein said:
<snip>
>>Of course, dereferencing that pointer
is completely undefined.

Right, which is why I consider the conversion meaningless.

So conversion to void * is always meaningless, because no void * can be
dereferenced?
Um, er... :-)

Okay, so that's an exception. But I think that, in general terms, it's
still a reasonable rule of thumb.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Oct 31 '07 #12
ca********@yahoo.com wrote:
Hi all,
I just came across the following program:

#include <stdio.h>
int main()
{
float a = 12.5;
printf("%d\n", a);
printf("%d\n", *(int *)&a);
return 0;
}

The program prints 0 and 1095237362. However, in my opinion it should
print 12 at both the places. Can anybody tell me where I am wrong?
As others have said, or tried to say, using the "%d" format specifier in
printf() does not convert the value of (a) to an int, and casting the
pointer &a to an int * does not change the value stored there into an
int. In both cases, what (usually) happens is that the bit pattern is
interpreted as an int. In other words, instead of *translating* to an
int, these cases merely point to the bit pattern of a float and *say*
that it's an int.

To convert the value of (a), you'd use something like

printf( "%d\n", ( int ) a );

This explicitly tells the compiler that you want printf() to see the int
value 12, rather than the floating-point value 12.5, and the compiler
therefore inserts code to change the bit pattern accordingly, before
printf() interprets it.

The C standard can't tell you why you got the specific values you did,
since they depend on your implementation. But we can make some pretty
safe inferences, and this might help you understand what happened.

Based on your numbers, your implementation is little-endian, it has
4-byte ints and floats and 8-byte doubles, and it uses IEEE floating-
point representation. Windows is the most common environment where
these conditions are true.

In the first case,

printf("%d\n", a);

(a) is promoted to a double, and printf() therefore receives the 8 bytes

00 00 00 00 00 00 29 40

When printf() encounters the "%d" format specifier, it looks at the next
four bytes in the argument list, because it's expecting an int to be
there. It sees 00 00 00 00, and prints "0".

In the second case,

printf("%d\n", *(int *)&a);

printf() receives the integer corresponding to the four bytes at the
address &a, which are

00 00 48 41

When interpreted as a little-endian 4-byte IEEE float, these bytes
represent the value 12.5. But when interpreted as a 4-byte int, they
represent the value you saw, 1095237632 decimal or 41480000 hex.

- Ernie http://home.comcast.net/~erniew
Oct 31 '07 #13
On Oct 31, 3:39 am, Peter Nilsson <ai...@acay.com.auwrote:
andreyvul <andrey....@gmail.comwrote:
Pointer casting does not convert values of one type
to another.

Yes it does. Indeed, all conversions do precisely that.
Casting a pointer from one type to another converts the
pointer value from the original pointer type to a pointer
value of the cast type. Only certain conversions (and
chains thereof) are guaranteed to be lossless.

What you meant to say is that converting pointers does
not convert the value of the object being pointed to,
if any.

--
Peter
You fixed my grammar typo. What I meant was *ptr being unconverted,
not ptr itself.

Oct 31 '07 #14
#include <stdio.h>
int main(void) {
float pi = 3.1415f;
printf("%d\n", (int)pi);
return 0;
}

simple

Oct 31 '07 #15
from c++ faq, section 27:
[27.11] Why do people worry so much about pointer casts and/or
reference casts?

Because they're evil! (Which means you should use them sparingly and
with great care.)

For some reason, programmers are sloppy in their use of pointer casts.
They cast this to that all over the place, then they wonder why things
don't quite work right. Here's the worst thing: when the compiler
gives them an error message, they add a cast to "shut the compiler
up," then they "test it" to see if it seems to work. If you have a lot
of pointer casts or reference casts, read on.

The compiler will often be silent when you're doing pointer-casts and/
or reference casts. Pointer-casts (and reference-casts) tend to shut
the compiler up. I think of them as a filter on error messages: the
compiler wants to complain because it sees you're doing something
stupid, but it also sees that it's not allowed to complain due to your
pointer-cast, so it drops the error message into the bit-bucket. It's
like putting duct tape on the compiler's mouth: it's trying to tell
you something important, but you've intentionally shut it up.

A pointer-cast says to the compiler, "Stop thinking and start
generating code; I'm smart, you're dumb; I'm big, you're little; I
know what I'm doing so just pretend this is assembly language and
generate the code." The compiler pretty much blindly generates code
when you start casting - you are taking control (and responsibility!)
for the outcome. The compiler and the language reduce (and in some
cases eliminate!) the guarantees you get as to what will happen.
You're on your own.

By way of analogy, even if it's legal to juggle chainsaws, it's
stupid. If something goes wrong, don't bother complaining to the
chainsaw manufacturer - you did something they didn't guarantee would
work. You're on your own.

(To be completely fair, the language does give you some guarantees
when you cast, at least in a limited subset of casts. For example,
it's guaranteed to work as you'd expect if the cast happens to be from
an object-pointer (a pointer to a piece of data, as opposed to a
pointer-to-function or pointer-to-member) to type void* and back to
the same type of object-pointer. But in a lot of cases you're on your
own.)

Oct 31 '07 #16
andreyvul wrote:
>
from c++ faq, section 27:
[27.11] Why do people worry so much about pointer casts and/or
reference casts?

Because they're evil! (Which means you should use them sparingly and
with great care.)

For some reason, programmers are sloppy in their use of pointer casts.
They cast this to that all over the place, then they wonder why things
don't quite work right. Here's the worst thing: when the compiler
gives them an error message, they add a cast to "shut the compiler
up," then they "test it" to see if it seems to work. If you have a lot
of pointer casts or reference casts, read on.

The compiler will often be silent when you're doing pointer-casts and/
or reference casts. Pointer-casts (and reference-casts) tend to shut
the compiler up. I think of them as a filter on error messages: the
compiler wants to complain because it sees you're doing something
stupid, but it also sees that it's not allowed to complain due to your
pointer-cast, so it drops the error message into the bit-bucket. It's
like putting duct tape on the compiler's mouth: it's trying to tell
you something important, but you've intentionally shut it up.

A pointer-cast says to the compiler, "Stop thinking and start
generating code; I'm smart, you're dumb; I'm big, you're little; I
know what I'm doing so just pretend this is assembly language and
generate the code." The compiler pretty much blindly generates code
when you start casting - you are taking control (and responsibility!)
for the outcome. The compiler and the language reduce (and in some
cases eliminate!) the guarantees you get as to what will happen.
You're on your own.

By way of analogy, even if it's legal to juggle chainsaws, it's
stupid. If something goes wrong, don't bother complaining to the
chainsaw manufacturer - you did something they didn't guarantee would
work. You're on your own.

(To be completely fair, the language does give you some guarantees
when you cast, at least in a limited subset of casts. For example,
it's guaranteed to work as you'd expect if the cast happens to be from
an object-pointer (a pointer to a piece of data, as opposed to a
pointer-to-function or pointer-to-member) to type void* and back to
the same type of object-pointer.
That's true, but a cast to type (void*)
is hardly ever applied to an object pointer in C.
An object pointer value can be assigned
to a (void*) object without a cast.

Casting an object pointer to type (char*) on the other hand,
gets you the address of the lowest addressable byte of the object.
But in a lot of cases you're on your own.)
--
pete
Nov 1 '07 #17
On Nov 1, 2:22 am, pete <pfil...@mindspring.comwrote:
That's true, but a cast to type (void*)
is hardly ever applied to an object pointer in C.
An object pointer value can be assigned
to a (void*) object without a cast.

Casting an object pointer to type (char*) on the other hand,
gets you the address of the lowest addressable byte of the object.
In value context, yes. In size context, no.

char *p;
char *s = (char*)(void*)p;

Consider the case where char * is 48 bits and void * is 32 bits. Or
two differend sizes anyway.
void * is only guaranteed to fit any pointer value.

Nov 1 '07 #18
On Nov 1, 1:10 am, vipvipvipvipvip...@gmail.com wrote:
Consider the case where char * is 48 bits and void * is 32 bits. Or
two differend sizes anyway.
void * is only guaranteed to fit any pointer value.
That is not possible, since all variants of char* and void* are
guaranteed to have the same representation.
Nov 1 '07 #19
vi****************@gmail.com wrote:
>
#include <stdio.h>
int main(void) {
float pi = 3.1415f;
printf("%d\n", (int)pi);
return 0;
}

simple
Simpler:
#include <stdio.h>
int main(void) {
puts("3");
return 0;
}
:-)

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
--
Posted via a free Usenet account from http://www.teranews.com

Nov 1 '07 #20
"Jack Klein" <ja*******@spamcop.neta écrit dans le message de news:
rf********************************@4ax.com...
On Wed, 31 Oct 2007 01:15:33 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote in comp.lang.c:
>ca********@yahoo.com said:
Hi all,
I just came across the following program:

#include <stdio.h>
int main()
{
float a = 12.5;
printf("%d\n", a);
printf("%d\n", *(int *)&a);
return 0;
}

The program prints 0 and 1095237362. However, in my opinion it should
print 12 at both the places. Can anybody tell me where I am wrong?

You are wrong in thinking that %d is the appropriate format specifier for
a
float, and you are wrong in thinking that you can meaningfully cast the
address of a float into the address of an int.

You were right in the first pronouncement, not necessarily so in the
second. The result of casting a pointer to an object or incomplete to
a pointer to any other object or incomplete type, is undefined if the
pointer is not suitably aligned for the second type, but well defined
if there is no alignment error. Of course, dereferencing that pointer
is completely undefined.
Is this true for ``printf("%u\n", *(unsigned char*)&a);'' ?

--
Chqrlie.
Nov 1 '07 #21
pete <pf*****@mindspring.comwrites:
[...]
Casting an object pointer to type (char*) on the other hand,
gets you the address of the lowest addressable byte of the object.
Casting to unsigned char* is probably better.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Nov 1 '07 #22
vi****************@gmail.com wrote:
>
On Nov 1, 2:22 am, pete <pfil...@mindspring.comwrote:
That's true, but a cast to type (void*)
is hardly ever applied to an object pointer in C.
An object pointer value can be assigned
to a (void*) object without a cast.

Casting an object pointer to type (char*) on the other hand,
gets you the address of the lowest addressable byte of the object.
In value context, yes. In size context, no.

char *p;
char *s = (char*)(void*)p;
I don't know what you mean
or what your code example is supposed to be showing.
Consider the case where char * is 48 bits and void * is 32 bits.
Or two differend sizes anyway.
There is no such case.

N869
6.2.5 Types
[#27] A pointer to void shall have the same representation
and alignment requirements as a pointer to a character type.

--
pete
Nov 1 '07 #23
Charlie Gordon wrote:
>
"Jack Klein" <ja*******@spamcop.neta écrit dans le message de news:
rf********************************@4ax.com...
The result of casting a pointer to an object or incomplete to
a pointer to any other object or incomplete type, is undefined
if the pointer is not suitably aligned for the second type,
but well defined if there is no alignment error.
Of course, dereferencing that pointer is completely undefined.

Is this true for ``printf("%u\n", *(unsigned char*)&a);'' ?
No. As long as the (unsigned char *) value,
points to an object, it can be dereferenced.
Indeterminate unsigned char values,
are merely unspecified, not undefined.

--
pete
Nov 1 '07 #24
http://groups.google.com/group/comp....b88c1a001346b7
A char * can be more or less bits than a void *.

Nov 1 '07 #25
On Nov 1, 8:54 am, vipvipvipvipvip...@gmail.com wrote:
http://groups.google.com/group/comp....d/thread/650ec...
A char * can be more or less bits than a void *.
You really should stop snipping all the context of your post. It makes
it hard to follow in certain newsreaders.

As regards your link, a Usenet post that may or may not be correct and
may or may not have anything to do with what you're trying to prove
anyways is not more authoritative than the text from the standard that
pete quoted.

Nov 1 '07 #26
vi****************@gmail.com wrote:
http://groups.google.com/group/comp....b88c1a001346b7
A char * can be more or less bits than a void *.
That Usenet article precedes the C89 standard by 9 months.

--
Philip Potter pgp <atdoc.ic.ac.uk
Nov 1 '07 #27
vi****************@gmail.com wrote:
>
A char * can be more or less bits than a void *.
You snipped Petes reply, which included the following:
There is no such case.

N869

6.2.5 Types
[#27] A pointer to void shall have the same representation
and alignment requirements as a pointer to a character type.
Obviously you are attempting to get PLONKED as an erroneous source.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Nov 1 '07 #28
vi****************@gmail.com wrote:
Casting an object pointer to type (char*) on the other hand,
gets you the address of the lowest addressable byte of the object.
In value context, yes. In size context, no.
I'm not making this stuff up.

N869
6.3.2.3 Pointers
[#7] When a pointer to an
object is converted to a pointer to a character type, the
result points to the lowest addressed byte of the object.

--
pete
Nov 1 '07 #29
In article <11**********************@o3g2000hsb.googlegroups. com>
<vi****************@gmail.comwrote:
>http://groups.google.com/group/comp....b88c1a001346b7
A char * can be more or less bits than a void *.
No, it must be the same size.

The URL above appears to refer to an article I wrote in 1989,
quoting something I wrote in 1988; both articles were written before
the original C standard was final (which was in December 1989, if
I remember right; the actual publication did not take place until
early 1990).

In any case, I was simply covering all possible bases when I said,
in effect, "if (void *) is the same as (char *), then call B is
wrong; but if it *not* the same as (char *), then call A is wrong".
The 1989 C Standard pinned down the details, which have not changed
since then: "void *" and "char *" have the same representation, so
they have the number of bits, and the same meaning for any
"non-padding" bits. So now we can say that it would have been call
B that would have been wrong. :-)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 1 '07 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

188
by: infobahn | last post by:
printf("%p\n", (void *)0); /* UB, or not? Please explain your answer. */
12
by: baumann | last post by:
hi all, printf("%c",b) doesn't work properly. #include <stdio.h> int a , b; char d, e; char * p; float f; int main(int argc, char* argv) {
9
by: geek | last post by:
Hi all, Why does a printf("%d") statement prints this as output and when I do printf("%c") it doesn't print anything. -13361016 Any help would be appreciated. Thanks,
2
by: Jude | last post by:
here is the source code: #include<stdio.h> int main() { float f; scanf("%d%f",&f); printf("The float is %10.5f\n",f); return 0; } when I input 12345.11111,the output is 12345.11133.
10
by: Jude | last post by:
here is the source code: #include<stdio.h> int main() { float f; scanf("%f",&f); printf("The float is %10.5f\n",f); return 0; }
19
by: v4vijayakumar | last post by:
why the following statement dumps the core(Segmentation fault)? printf("%s\n", __FILE__);
12
by: Zero | last post by:
Hi everybody, i want to write a small program, which shows me the biggest and smallest number in dependance of the data type. For int the command could be: ...
13
by: Ioannis Vranos | last post by:
If we want to print a float with printf, a printf("%f", x); is sufficient, or a cast is needed like in printf("%f", (double)x); ?
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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...
0
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...
0
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
1
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.