%ls C89?

S

Servé Lau

Is the %ls format specifier C99 or was it also in C89? For me this is a very
handy feature

#include <stdio.h>
#include <wchar.h>

int main(void) {
wchar_t buf[128];

sscanf("hello", "%ls", buf);

fwprintf(stdout, buf);

return 0;
}
 
K

Kevin Goodsell

Servé Lau said:
Is the %ls format specifier C99 or was it also in C89? For me this is a very
handy feature

As far as I can tell, 'l' cannot be used as a length modifier for 's',
'c', or '[' in C89.
#include <stdio.h>
#include <wchar.h>

int main(void) {
wchar_t buf[128];

sscanf("hello", "%ls", buf);

fwprintf(stdout, buf);

return 0;
}

Neither <wchar.h> nor fwprintf() exist in C89, either (they were added
with Normative Addendum 1, so they are part of C95).

-Kevin
 
S

Servé Lau

Kevin Goodsell said:
Servé Lau said:
Is the %ls format specifier C99 or was it also in C89? For me this is a very
handy feature

As far as I can tell, 'l' cannot be used as a length modifier for 's',
'c', or '[' in C89.

hmmm, pretty handy that one :)
 
K

Kevin Goodsell

Servé Lau said:
Servé Lau wrote:

Is the %ls format specifier C99 or was it also in C89? For me this is a
very
handy feature

As far as I can tell, 'l' cannot be used as a length modifier for 's',
'c', or '[' in C89.


hmmm, pretty handy that one :)

Also, I just noticed that the 'l' length modifier was also added for the
printf and scanf functions with Normative Addendum 1, so they are C95
and C99, but not C89. C95 is fairly wide-spread I think, so you may be
OK to use them. gcc and MS Visual C both support C95, I believe.

-Kevin
 
S

Servé Lau

Kevin Goodsell said:
Also, I just noticed that the 'l' length modifier was also added for the
printf and scanf functions with Normative Addendum 1, so they are C95
and C99, but not C89. C95 is fairly wide-spread I think, so you may be
OK to use them. gcc and MS Visual C both support C95, I believe.

It works on VC2003 and lcc-win32 at least. Does anybody know if this works
on Borland C++Builder 5? (don't have access to it at the moment)
 
D

Dan Pop

In said:
Servé Lau said:
Servé Lau wrote:


Is the %ls format specifier C99 or was it also in C89? For me this is a
very

handy feature

As far as I can tell, 'l' cannot be used as a length modifier for 's',
'c', or '[' in C89.


hmmm, pretty handy that one :)

Also, I just noticed that the 'l' length modifier was also added for the
printf and scanf functions with Normative Addendum 1, so they are C95
and C99, but not C89. C95 is fairly wide-spread I think, so you may be
OK to use them. gcc and MS Visual C both support C95, I believe.

Since we're talking about library features, gcc's support for C95 is
irrelevant.

I've no idea how widely implemented the C95 library features are.

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top