printf() Specification for size_t?

  • Permalink
  • submit to reddit
  • Email
  • Follow


What printf() format specifier will allow me to print a size_t integer?

Seems like it should be there, but couldn't find it in documentation.

I'm using %ul, but that might not work on every system, I think.

Thanks.

--
David T. Ashley              (dta@e3ft.com)
http://www.e3ft.com          (Consulting Home Page)
http://www.dtashley.com      (Personal Home Page)
http://gpl.e3ft.com          (GPL Publications and Projects)
0
Reply dta (455) 2/21/2008 2:51:02 AM

See related articles to this posting


In article <ZbednabdyeYqeiHanZ2dnUVZ_gydnZ2d@giganews.com>,
David T. Ashley <dta@e3ft.com> wrote:
>What printf() format specifier will allow me to print a size_t integer?
>
>Seems like it should be there, but couldn't find it in documentation.
>
>I'm using %ul, but that might not work on every system, I think.

For C90, cast it to unsigned long and use %lu:
--------
printf("The size_t value is %lu\n",(unsigned long)sz);
--------
If you have C99, use %zu.

Note that %lu and %ul are not the same.


dave

-- 
Dave Vandervies                             dj3vande at eskimo dot com
Interestingly the venom isn't poisonous in the traditional sense, it's
just a very powerful relaxant. You relax to the point where you don't
breath.                --Andrew Nicholson in the scary devil monastery
0
Reply dj3vande3 (264) 2/21/2008 3:12:54 AM

"David T. Ashley" <d...@e3ft.com> wrote:
> What printf() format specifier will allow me to print
> a size_t integer?

Under C90, you should use the largest (portable)
unsigned integer type, namely unsigned long...

  printf("%lu\n", (unsigned long) sizeof x);

Under C99, you can use the length modifier z...

  printf("%zu\n", sizeof x);

> Seems like it should be there, but couldn't find
> it in documentation.
>
> I'm using %ul,

Which will print an unsigned int value followed by an
ell.

> but that might not work on every
> system, I think.

Using unsigned long (uncluding conversion) is reasonably
forwards compatible. That said, it's possible to cater
for both worlds with some conditional includes and macros,
but it generally isn't worth the hassle since it's
relatively rare to print a size_t without knowing limits
on how big the object that it refers to can reasonably
be.

For instance, if you're dealing with objects that might
be larger than 4G, then you're more likely to be printing
the size in megabytes or gigabytes. Either way the integer
calculation is likely to be in the range of an unsigned
long.

--
Peter
0
Reply airia (1802) 2/21/2008 3:24:51 AM

<dj3vande@csclub.uwaterloo.ca.invalid> wrote in message 
news:fpiq7m$6om$1@rumours.uwaterloo.ca...
> In article <ZbednabdyeYqeiHanZ2dnUVZ_gydnZ2d@giganews.com>,
> David T. Ashley <dta@e3ft.com> wrote:
>>What printf() format specifier will allow me to print a size_t integer?
>>
>>Seems like it should be there, but couldn't find it in documentation.
>>
>>I'm using %ul, but that might not work on every system, I think.
>
> For C90, cast it to unsigned long and use %lu:
> --------
> printf("The size_t value is %lu\n",(unsigned long)sz);
> --------
> If you have C99, use %zu.
>
> Note that %lu and %ul are not the same.

I had a brain malfunction.  I actually used %lu, which worked fine, but 
somehow in the newsgroup post I stated "%ul".

I'm aware that on my platform, "lu" works fine (naturally, I looked up the 
size_t definition before I did this).

My only fear (and the reason I made the post) is that I could envision 
platforms where the largest integer has far more bits than the address space 
of the machine.  I've never seen such a thing, but it seems it could exist.

In other words, I can't figure out why size_t _____necessarily_____ has any 
relationship to the largest integer size. 

0
Reply dta (455) 2/21/2008 5:11:28 AM

"Peter Nilsson" <airia@acay.com.au> wrote in message 
news:288c586d-1c48-4afc-94cb-336ecc503bf4@d4g2000prg.googlegroups.com...
> "David T. Ashley" <d...@e3ft.com> wrote:
>> What printf() format specifier will allow me to print
>> a size_t integer?
>
> Using unsigned long (uncluding conversion) is reasonably
> forwards compatible. That said, it's possible to cater
> for both worlds with some conditional includes and macros,
> but it generally isn't worth the hassle since it's
> relatively rare to print a size_t without knowing limits
> on how big the object that it refers to can reasonably
> be.
>
> For instance, if you're dealing with objects that might
> be larger than 4G, then you're more likely to be printing
> the size in megabytes or gigabytes. Either way the integer
> calculation is likely to be in the range of an unsigned
> long.

I had a brain malfunction.  I actually used %lu, which worked fine, but 
somehow in the newsgroup post I stated "%ul".

I'm aware that on my platform, "lu" works fine (naturally, I looked up the 
size_t definition before I did this).

My only fear (and the reason I made the post) is that I could envision 
platforms where the largest integer has far more bits than the address space 
of the machine.  I've never seen such a thing, but it seems it could exist.

In other words, I can't figure out why size_t _____necessarily_____ has any 
relationship to the largest integer size. 

0
Reply dta (455) 2/21/2008 5:12:31 AM

David T. Ashley wrote:
> What printf() format specifier will allow me to print a size_t integer?
> 
> Seems like it should be there, but couldn't find it in documentation.
> 
> I'm using %ul, but that might not work on every system, I think.

"%ul" should never work, while "%lu" often will.

If you have a library supporting the C99 specifier "%zu", use that.
Otherwise, you can't get much safer than
      "%llu" with a cast to (unsigned long long)
If your implementation supports neither, then use
      "%lu" with a cast to (unsigned long)
and pray.

0
Reply mambuhl (2202) 2/21/2008 6:04:55 AM

Martin Ambuhl said:

> David T. Ashley wrote:
>> What printf() format specifier will allow me to print a size_t integer?
>> 
>> Seems like it should be there, but couldn't find it in documentation.
>> 
>> I'm using %ul, but that might not work on every system, I think.
> 
> "%ul" should never work, while "%lu" often will.

I see no reason why %ul should not work. There is nothing to stop 
implementors from using unsigned ints as the underlying type for size_t, 
and there is nothing to stop programmers from putting an 'l' onto stdout 
immediately after the size value.

-- 
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
0
Reply rjh (10790) 2/21/2008 8:00:28 AM

"David T. Ashley" <dta@e3ft.com> writes:
> <dj3vande@csclub.uwaterloo.ca.invalid> wrote in message
> news:fpiq7m$6om$1@rumours.uwaterloo.ca...
>> In article <ZbednabdyeYqeiHanZ2dnUVZ_gydnZ2d@giganews.com>,
>> David T. Ashley <dta@e3ft.com> wrote:
>>>What printf() format specifier will allow me to print a size_t integer?
>>>
>>>Seems like it should be there, but couldn't find it in documentation.
>>>
>>>I'm using %ul, but that might not work on every system, I think.
>>
>> For C90, cast it to unsigned long and use %lu:
>> --------
>> printf("The size_t value is %lu\n",(unsigned long)sz);
>> --------
>> If you have C99, use %zu.
>>
>> Note that %lu and %ul are not the same.
>
> I had a brain malfunction.  I actually used %lu, which worked fine,
> but somehow in the newsgroup post I stated "%ul".
>
> I'm aware that on my platform, "lu" works fine (naturally, I looked up
> the size_t definition before I did this).
>
> My only fear (and the reason I made the post) is that I could envision
> platforms where the largest integer has far more bits than the address
> space of the machine.  I've never seen such a thing, but it seems it
> could exist.
>
> In other words, I can't figure out why size_t _____necessarily_____
> has any relationship to the largest integer size. 

size_t is necessarily no bigger than the largest integer size.
There's no guarantee that it's the same as any particular predefined
integer type, which is why (unless you have "%zu") you have to convert
it to some type to print it.

In C90, the largest unsigned integer type (size_t is guaranteed to be
an unsigned type) is unsigned long, so this:

    size_t size = <whatever>;
    printf("size = %lu\n", (unsigned long)size);

should always work.  In C99, unsigned long long isn't guaranteed to be
the widest unsigned integer type (an implementation can provide
extended integer types), and it's conceivable that size_t could be
wider than unsigned long.  It's guaranteed that size_t is no wider
than uintmax_t, but since C99 provides formats for both size_t and
uintmax_t that isn't all that helpful.

If you need portability to both C90 and C99 implementations, you can
still use the "%lu" trick *if* you can guarantee that the particular
value you're printing is no greater than ULONG_MAX.  Even if size_t is
wider than unsigned long, if the value doesn't exceed ULONG_MAX then
the cast performs a (narrowing) conversion that doesn't lose any
information.  (Even if the value is greater than ULONG_MAX, the
semantics of unsigned types means that you'll just get an incorrect
result; there's no undefined behavior.)

If you know your code will run only under conforming C99
implementations, you can use "%zu" (and there's no need for a cast).
But note that, out in the real world, even testing for
__STDC_VERSION__ >= 199901L doesn't necessarily guarantee that "%zu"
will work.  The __STDC_VERSION__ macro is set by the compiler; it's up
to the runtime library to implement printf properly.  An
implementation combining a compiler and a runtime library *should* get
this right, but I think that some don't.

-- 
Keith Thompson (The_Other_Keith) <kst-u@mib.org>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
0
Reply kst-u (21963) 2/21/2008 8:21:28 AM

Richard Heathfield wrote:
> Martin Ambuhl said:
> 
>> David T. Ashley wrote:
>>> What printf() format specifier will allow me to print a size_t integer?
>>>
>>> Seems like it should be there, but couldn't find it in documentation.
>>>
>>> I'm using %ul, but that might not work on every system, I think.
>> "%ul" should never work, while "%lu" often will.
> 
> I see no reason why %ul should not work. There is nothing to stop 
> implementors from using unsigned ints as the underlying type for size_t, 
> and there is nothing to stop programmers from putting an 'l' onto stdout 
> immediately after the size value.

Thank you for your valuable contribution.

0
Reply mambuhl (2202) 2/21/2008 9:14:58 AM

Martin Ambuhl said:

> Richard Heathfield wrote:
>> Martin Ambuhl said:
>> 
>>> David T. Ashley wrote:
>>>> What printf() format specifier will allow me to print a size_t
>>>> integer?
>>>>
>>>> Seems like it should be there, but couldn't find it in documentation.
>>>>
>>>> I'm using %ul, but that might not work on every system, I think.
>>> "%ul" should never work, while "%lu" often will.
>> 
>> I see no reason why %ul should not work. There is nothing to stop
>> implementors from using unsigned ints as the underlying type for size_t,
>> and there is nothing to stop programmers from putting an 'l' onto stdout
>> immediately after the size value.
> 
> Thank you for your valuable contribution.

You're quite welcome, my dear chap!

-- 
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
0
Reply rjh (10790) 2/21/2008 10:33:37 AM

Richard Heathfield wrote:
> Martin Ambuhl said:
>> David T. Ashley wrote:
>>
>>> What printf() format specifier will allow me to print a size_t
>>> integer?  Seems like it should be there, but couldn't find it
>>> in documentation.  I'm using %ul, but that might not work on
>>> every system, I think.
>>
>> "%ul" should never work, while "%lu" often will.
> 
> I see no reason why %ul should not work. There is nothing to
> stop implementors from using unsigned ints as the underlying
> type for size_t, and there is nothing to stop programmers from
> putting an 'l' onto stdout immediately after the size value.

I think this will create great confusion for newbies.  It should be
labelled, etc. to attempt to avoid being taken too seriously.

-- 
 [mail]: Chuck F (cbfalconer at maineline dot net) 
 [page]: <http://cbfalconer.home.att.net>
            Try the download section.



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

0
Reply cbfalconer (19194) 2/21/2008 1:53:54 PM

On Feb 21, 3:53 pm, CBFalconer <cbfalco...@yahoo.com> wrote:
> Richard Heathfield wrote:
> > Martin Ambuhl said:
> >> David T. Ashley wrote:
>
> >>> What printf() format specifier will allow me to print a size_t
> >>> integer?  Seems like it should be there, but couldn't find it
> >>> in documentation.  I'm using %ul, but that might not work on
> >>> every system, I think.
>
> >> "%ul" should never work, while "%lu" often will.
>
> > I see no reason why %ul should not work. There is nothing to
> > stop implementors from using unsigned ints as the underlying
> > type for size_t, and there is nothing to stop programmers from
> > putting an 'l' onto stdout immediately after the size value.
>
> I think this will create great confusion for newbies.  It should be
> labelled, etc. to attempt to avoid being taken too seriously.
It would also confuse a newbie to think that %ul would print an
unsigned long.
When printf() encounters a % in the string literal, it searches for
one of the conversion specifiers, which are
d,i,a,u,x,X,f,F,e,E,g,G,a,A,c,s,p,n,%, and also parses any flag
characters, length modifiers, precision and field width which are
optional.
When not doing that, printf() simply puts the bytes to stdout.
So, according to that, %ul would be parsed as:
%: start parsing
u: valid conversion specifier. stop parsing
l: byte. put (write) to stdout

Hope this clears any confusion a newbie might had.

Reference: 7.19.6.1 ISO C99
0
Reply vippstar (1211) 2/21/2008 3:10:18 PM

On 21 Feb 2008 at 10:33, Richard Heathfield wrote:
> Martin Ambuhl said:
>
>> Richard Heathfield wrote:
>>> Martin Ambuhl said:
>>> 
>>>> David T. Ashley wrote:
>>>>> What printf() format specifier will allow me to print a size_t
>>>>> integer?
>>>>>
>>>>> Seems like it should be there, but couldn't find it in documentation.
>>>>>
>>>>> I'm using %ul, but that might not work on every system, I think.
>>>> "%ul" should never work, while "%lu" often will.
>>> 
>>> I see no reason why %ul should not work. There is nothing to stop
>>> implementors from using unsigned ints as the underlying type for size_t,
>>> and there is nothing to stop programmers from putting an 'l' onto stdout
>>> immediately after the size value.
>> 
>> Thank you for your valuable contribution.
>
> You're quite welcome, my dear chap!

Ouch! Twice the sarcasm cuts like a knife as we one again play "clc
regulars eating their own"...

0
Reply nospam59 (11087) 2/21/2008 6:38:41 PM

David T. Ashley wrote:
> 
> <dj3vande@csclub.uwaterloo.ca.invalid> wrote in message
> news:fpiq7m$6om$1@rumours.uwaterloo.ca...
> > In article <ZbednabdyeYqeiHanZ2dnUVZ_gydnZ2d@giganews.com>,
> > David T. Ashley <dta@e3ft.com> wrote:
> >>What printf() format specifier
> >>will allow me to print a size_t integer?
> >>
> >>Seems like it should be there,
> >>but couldn't find it in documentation.
> >>
> >>I'm using %ul, but that might not work on every system, I think.
> >
> > For C90, cast it to unsigned long and use %lu:
> > --------
> > printf("The size_t value is %lu\n",(unsigned long)sz);
> > --------
> > If you have C99, use %zu.
> >
> > Note that %lu and %ul are not the same.
> 
> I had a brain malfunction.
> I actually used %lu, which worked fine, but
> somehow in the newsgroup post I stated "%ul".

That's why I call it (long unsigned) instead of (unsigned long).

-- 
pete
0
Reply pfiland (6614) 2/21/2008 9:40:46 PM
comp.lang.c 29432 articles. 31 followers. Post

13 Replies
85 Views

Similar Articles

[PageSpeed] 49


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

printf and size_t
Should the following work *if* I have a c99 compiler please? #include <stdio.h> int main(void) { size_t t = 42; # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99, so it should support %zu? */ printf("%zu", t); # else /* Not a C99 compiler - use lu. */ printf("%lu", (unsigned long)t); # endif return 0; } I'm using gcc 3.4.2 and the output is zu, this, I believe, shows that the printf supplied doesn't recognize %zu as a valid format specifier? BTW, where would y...

printf specifications
Microsoft has proposed using %I64d to print a long long. Lcc-win has adapted this to %I32d, %I64d, %I128d or %I32u, %I64u, %I128u This specifications would be an addition to the "h" or "l" (lower case L) specifications Is there anything planned in this directionby the standards committee? Thanks in advance for any answers jacob jacob navia writes: > Microsoft has proposed using > > %I64d to print a long long. this would be quite misleading on machines where long long is 128 bits > Lcc-win has adapted this to > > %...

printf conversion specification
Acc. to C99, in printf(), if any argument is not the correct type for correspnding conversion specifier, the behaviour is undefined. I want to know that does that happen everytime. I mean in this program int main() { int num=32; printf("%ld",num); } Is it ub? bauran <hppymittal@yahoo.com> writes: > Acc. to C99, in printf(), if any argument is not the correct type for > correspnding conversion specifier, > the behaviour is undefined. > > I want to know that does that happen everytime. > I mean in this program > int main() > { > int num=32; > ...

printf formats for size_t?
size_t varies from system to system. This occasionally leads to coding issues such as: (void) sprintf(msg,"length of buffer: %d",strlen(msg)); which worked fine on a 32 linux but triggered errors with gcc on an X86_64 system. (Ok, it should probably have been a %u rather than a %d, but since msg was always going to be short it didn't affect the program's execution.) The gcc printf man page indicates that "%zu", "%zx", etc. tell the compiler that the variable has type size_t, whatever size_t happens to be. Is "z" part of the C standard ...

Portable way to printf() a size_t instance
Hello, I have code which makses use of variables of type size_t. The code is originally developed on a 32 bit machine, but now it is run on both a 32 bit and a 64 bit machine. In the code have statements like this: size_t buffer_size; printf("Total buffer size: %ud bytes \n",buffer_size); Now the format "%ud" works nicely on the 32 bit computer; it actually works on the 64 bit computer as well, but the compiler spits out warning message. On the 64 bit computer it would have prefered: printf("Total buffer size: %uld bytes \n",buffer_size); /* Or udl? */...

gcc printf conversion specification for struct timeval
Hallo group members, Do You know any conversion specification for this. I imagine: struct timeval time; printf("%T\n", time); regards, Pawel PawelCarqowski wrote: > Hallo group members, > Do You know any conversion specification for this. I imagine: > > struct timeval time; > printf("%T\n", time); struct timeval is a GNU C extension. There are no specific format specifiers for this but since the structure members are of type long int you can use the 'ld' format specifier for printing them. For furher GNU C related questions please ask in a GNU ...

why use fprintf / size_t instead of printf/ int
E. Robert Tisdale wrote: > > int main(int argc, char* argv[]) { > quad_t m = {0, 1, 2, 3}; > int r; > fprintf(stdout, "m = ("); > for (size_t j = 0; j < 4; ++j) Why did you declare j as type size_t ? > fprintf(stdout, " %d", m[j]); > fprintf(stdout, ")\n"); WHy did you use fprintf here? > w0(&r, m); > fprintf(stdout, "r = %d\n", r); > return 0; I'm only asking because I'm one of those people w...

64 bit portability, size_t, and printf format strings
http://msdn2.microsoft.com/en-us/library/tcxf1dw6.aspx describes the integer format modifiers accepted by Microsoft's printf. http://www.gnu.org/software/libc/manual/html_node/Integer-Conversions.html describes the integer format modifiers accepted by glibc's printf. They differ (no big surprise), but the difference that's bugging me today is how size_t integers are handled. It looks like one has to do %Id (that's a capital i) in windows, and %zd everywhere else. This didn't use to matter much, but now that 64 bit portability is becoming important, source code that used t...

overloading operator delete[](void*, size_t)
Hi, should s be equal in the call of new[] and in the call of delete[] in the following example, as it is with g++? With MSVC++2010 (and 2005) it is not. #include <iostream> using namespace std; class C { public: int j; void* operator new[]( size_t s ) { cout << "new[]: size_t=" << s << endl; return ::operator new[]( s ); } void operator delete[]( void* ptr, size_t s ) { cout << "delete[]: size_t=" << s << endl; } }; int main() { C* x = new C[100]; delete[] x; return 0; } Is this an inco...

Filling in Textboxes with a specific value from a specific record in a specific table.
Hello, I've been waisting tons of time on this, so I'll just ask and hopefully someone will be able to help. I am opening an excel document and placing values into it's "letterhead" section (i have no problem doing this). The values that I am writing to the excel document come from a couple different tables. I am displaying the set of values on a form for the user to see. once they approve and click a button, the code takes those values in the textboxes and writes them to the excel document. I have not set the recordsource property for the form, cause its not like it...

Extracting printf(...) from (void) printf(....)
HI all How to search for (void) from the line. ex: (void) printf(....) I want to search if (void) is there at the beggining of the line.. if exist then extract printf(....) function. Please let me know how it can be done or tell me the reference so that I can try. Thanks & Regards Gururaja On Feb 2, 9:04 am, guru <guru.nav...@gmail.com> wrote: > HI all > > How to search for (void) from the line. > > ex: (void) printf(....) > > I want to search if (void) is there at the beggining of the line.. if > exist then extract printf(....) function. > > Plea...

Sun-specific or SVR4 specific?
Porting one program from Linux to Solaris, I've found out that struct tm on the Solaris doesn't contain tm_gmtoff member, and external variable altzone should be used instead. Is this behavoir Solaris-specific or it is common for all System V systems? Should I hide processing of altzone variable under #ifdef __sun__ or under #ifdef __svr4__ ? -- On Wed, 10 Sep 2003, Victor Wagner wrote: > Porting one program from Linux to Solaris, I've found out that > struct tm on the Solaris doesn't contain tm_gmtoff member, and external > variable altzone should be used ins...

(void) printf vs printf
Hi, c.l.cs I noticed that someone like add (void) before the printf call, like: (void) printf("Timeout\n"); while the others does't. So can someone tell me whether there any gains in adding (void) to printf. Thanks, Whatluo. In article <1117085321.411019.169790@g44g2000cwa.googlegroups.com>, whatluo <whatluo@gmail.com> wrote: >I noticed that someone like add (void) before the printf call, >like: (void) printf("Timeout\n"); while the others does't. So >can someone tell me whether there any gains in adding >(void) to printf. It can sile...

printf
Hello, How to print formatted text in java? For example I need to print int=55 in hex format. Thank You column.column@gmail.com writes: > How to print formatted text in java? For example I need to print > int=55 in hex format. As you said in the subject: printf System.out.printf("%2x%n", 55); <URL:http://java.sun.com/j2se/1.5.0/docs/api/java/io/PrintStream.html#printf(java.lang.String, java.lang.Object...)> /L -- Lasse Reichstein Nielsen - lrn@hotpop.com DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> 'Faith without judg...

printf
Dear all I use printf to avoid newline in my script like this ~~~~~~~~~~~~~~~~~~~~~~~~~~~~omittion for ( foo in name ) printf foo ":" name[foo]"+" >> "other.data" but i open the "other.data" by "vi" it tells me "Incomplete last line" how can I avoid this message? Thank you very much Jui-Hua On 21 Oct 2004 02:56:12 -0700, juihuahsieh@nhri.org.tw (moggces) wrote: >Dear all > >I use printf to avoid newline in my script >like this > >~~~~~~~~~~~~~~~~~~~~~~~~~~~~omittion >for ( foo in name ) >printf ...

printf
Are these functions thread safe in RedHat AS4 using rhel-ewuzhgu:% g++ -v Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.5/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux Thread model: posix gcc version 3.4.5 20051201 (Red Hat 3.4.5-2) Thanks Much for your attention, is there a place to find answers to such questions without having to post to the newsgroup and...

Printf
Hi, Can i ask the question: If you have an integer(int), how to print it out without using printf? Thanks "hello123" <nelson_yu@hotmail.com> wrote in message news:63f23995.0404220644.be37d0e@posting.google.com... > Hi, > > Can i ask the question: > > If you have an integer(int), how to print it out without using printf? > > Thanks by getting a book and reading about C. If you have to ask this then you will have a lot of trouble with C. here is the most basic way of printing out an integer using printf, there are howver many other things that can be...

size_t
Can somebody please give me some rules of thumb about when I should be using size_t instead of for example int ? Is size_t *always* typedef'd as the largest unsigned integral type on all systems ? I know that the strlen() functions and such returns a size_t, and it should be received that way. I am at the time creating some sort of cryptolibrary. Should all my API methods use size_t parameters instad of for example int parameters, and why ? And..Should I bother using size_t other places than when stdlib functions need/return then in my library? (If yes, why?) I bother because my cod...

size_t
This might be stupid thing to ask, but is the sizeof(size_t) supposed to be same size as sizeof(void*) ? I need to store representation of pointer into integer variable so that I can do arithmetics on it (bitwise xor), if not, what you gurus would recommend? assaarpa wrote in news:cig4jv$au1$1@phys-news1.kolumbus.fi in comp.lang.c++: > > This might be stupid thing to ask, but is the sizeof(size_t) supposed > to be same size as sizeof(void*) ? No, it might be, but it isn't gauranteed. > I need to store representation of > pointer into integer variable so that I can ...

Is compiler OS specific or Hardware specific....
hi, i have following doubts. is compiler OS specific or Hardware specific i.e processor specific.?? the confusion is because of the following (half ??)knowledge.. if the compiler is OS specific then one must know the internals of the OS!!! but since the OS like windows are proprietary and don't reveal any source code then how the compiler is designed for such an OS?? is it purely dependent on the processor architecture then??? also how the JVM for windows was made despite sun not knowing any of windows details?? or do OS vendors distribute kernel apis??? regds, yogesh ps. I post the same ...

Read specific field of specific record
I'm attempting to build a module that will allow me to update one field of a record (using a value from a previous record) based on the value of another field in the same record. I can successfully "cycle" through the records one at a time and get to the appropriate field as well, but any attempt to read the field values (using SELECT, of DoCmd.RunSQL "SELECT....) result in errors. I've searched the help file and this newsgroup but haven't found an answer. Any help greatly appreciated. Thanx Chuck Currentdb.execute "Update mytable set myfield = " &a...

How to distribute specific tasks to specific subkernels?
Hi, I am having trouble on using the automatic "Parallelize" to do my parallel computations, and I would like to know if there is a straightforward way to manually select which tasks should be run in each subkernel. A workaround I know is to open multiple Mathematica sessions, but there should be a less time-consuming option. Thanks for the help. Davi On Thu, 22 Sep 2011 12:29:58 +0100, Davi <davi3070008@me.com> wrote: > Hi, > > I am having trouble on using the automatic "Parallelize" to do my > parallel computations, and I would ...

Search a specific directory on a specific drive
I have been trying to edit the Explorer example by Dev Ashish I found on www.msvp.org (I think). I have been all over the net so I am not quite sure where the file came from. I like the way it works but I can not find a way to tell it to display a certain directory. I want it to display a folder on our share drive. I know the path for the directory. I want users to be able to open any files below the parent directory I tell it to start in. So, I don't want to to search for all the drives on the user's computer. I am very new to programming in VB and need detailed instructions if possib...

printf() in Perl vs. printf() in C
Hello: I believe common wisdom in C says that only an integer value can be correctly printed out by a '%d' conversion specifier in the format string of a printf. If the argument given to printf for a particular '%d' is not an integer, the output could be MEANINGLESS (at least theoretically). Now consider the case in Perl when printf() with a '%d' conversion specifier is asked to output a number. Since ALL numbers in Perl are stored as double-precision floats, Perl must first convert the internally stored number presentat...