J
James Kuyper
George said:Yikes. My references appear to be outdated here.
The 'vscanf' family of functions is new in C99.
....
The snprintf() family is also new in C99.
George said:Yikes. My references appear to be outdated here.
Nick said:and it what way are the definitions of the scanf() functions
"ambiguous"? I don't think they are ambiguous therefore I don't
think they need disambiguating. Do you simply mean you don't
know what scanf/sscanf/fscanf do?
The 'vscanf' family of functions is new in C99.
...
The snprintf() family is also new in C99.
George said:That's good to know from a source more authoratative than my outdated
references. I was hoping to get your opinion on q2 and q3.
George said:That's good to know from a source more authoratative than my outdated
references. I was hoping to get your opinion on q2 and q3.
all the ones that don't start with v
q2) What can a variadic function do that a garden-variety function can't?
take a [variable] number of arguments
I've no idea what "optional value arguments" are
line 42 reverses the polarity of the rabbit
what?
I don't see why it needs a funny name it same like basic
good programming practice that applies to any programming
language.
<snip>
Doesn't your platform have documentation? If not, upgrade to one that does!
George said:I must think of platform as something different than you do. I think I'm
on the windows platform using gcc for windows as an implementation.
snprintf() in windows documentation makes no sense. I've been taking steps
to getting on the gcc mailing list, it just hasn't happened yet.
George said:On Sat, 22 Nov 2008 12:02:32 GMT, James Kuyper wrote: [...]
vfscanf
vscanf
vsscanf
swscanf
fwscanf
vfwscanf
vswscanf
vwscanf
wscanf
To decode those names: a prefix of 'f' means that it reads from a
specified file, 's' reads from a character string, and if neither is
present it reads from stdin. A prefix of 'v' means that takes a va_list
argument instead of a variable argument list, and a 'w' means that it
reads from a wchar_t source instead of a char source.
Yikes. My references appear to be outdated here. I haveno reason to go
with something other than fgets/sscanf for this little project, but since
you've created this list, maybe you could comment on a couple questions.
I'm very interested in c/fortran interop, and one of the things that you
can't call as per F03 is a C function that is variadic.
q1) Which of the above are variadic?
all the ones that don't start with v
Huh? Are you sure?
q2) What can a variadic function do that a garden-variety function can't?
take a [variable] number of arguments
But what good is it? Have you ever used a variadic function and said,
"whew it was a good thing I had that variadic function because ______."
[...]
You have to divine what a subroutine does by clues likes 'f','d', and 's'
in its name. Then you read the subroutine to see if you guessed correctly.
If you don't guess correctly soon, it turns into a long night.
#include <stdio.h>
#include <stdlib.h>
#define PATH "george.txt"
#define NUMBER 100
#define BIN 1000
#define MAXFMTLEN 2000
int main(void)
{
FILE *fp;
char pattern[MAXFMTLEN];
char lnumber[NUMBER];
char lbin[BIN];
char line[MAXFMTLEN];
/*int line_num;
char data[32];*/
if ((fp = fopen(PATH, "r")) == NULL ) {
fprintf(stderr, "can't open file\n");
exit(1);
}
sprintf(pattern, "%%%ds %%%ds", BIN-1, NUMBER-1);
Can you explain this sprintf?
James said:George wrote:
.... snip ...
Nick's answer to q2 was perfectly correct; unlike CBFalconer, I
bother to check what other people have already answered before
I post my own answer.
I fail to see how the gcc mailing list would be helpful here. gcc
doesn't provide an implementation of snprintf; that's part of the
standard library. (gcc is a compiler, not a complete implementation.
It uses whatever C library is available on the system. This may or
may not be glibc, which is a separate GNU project.)
Get a copy of H&S5 (Harbison & Steele, 5th edition).
Get a copy of the latest draft of the C99 standard,
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf which is
less user-friendly, but has the virtue of being free.
I was referring to Unix man pages. I don't know how people can workGeorge said:I must think of platform as something different than you do. I think I'm
on the windows platform using gcc for windows as an implementation.
George said:But I lack the experience to keep them separate. gfortran, for example, is
implemented with c. When I subscribed to them, I thought I was getting
flashbacks.
Nate Eldridge informed me of the gcc mailing list option to digest them, so
they end up as one e-mail a day. I do not fail to see how the gcc mailing
list will be helpful.
I think it's the appropriate response to when someone tells you to RTFM.
My Minnesota attorney insulted me today, so this will be what Santa wants
under george's tree for Christmas.
I've got it. It's the only standard I've spent almost as much time with as
the fortran standard. While I've got your attention, I'd like to see the
same no bullshit definitions that you have in the fortran standard, eg:
datum : a single piece of information
data: plural of datum
Why bother? If the message to which you are replying is reasonably
composed, it already quotes all the necessary references. And any
independent messages you may happen to see may not now, or ever, be
visible to other readers. You seem to feel that answering a
message requires first reviewing something like 100 (maybe more,
maybe less) other messages hooked to the same thread.
And, if you do mention such things as my habits in order to
criticize, it would appear to be reasonable to quote the allegedly
failed reply, etc. Notice that your message is rather meaningless,
since it appears to revolve around the entities q2 and q3, which
are undefined, are mentioned as being questioned, without stating
the questions, etc.
There does not appear to be any dictum against applying
intelligence to message quoting.
Lots of people work with something called a "BOOK" or "MANUAL".Ian said:I was referring to Unix man pages. I don't know how people can work
(especially without internet connectivity) on a platform without "man".
You were asking about snprintf, or at least commenting on the lack of
good documentation for it. Since gcc doesn't provide snprintf, I fail
to see how subscribing to the gcc mailing list will be helpful with
the specific problem of finding documentation for snprintf. It may
well be helpful for other purposes, and I didn't mean to imply
otherwise.
Incidentally, I think the gcc lists are gatewayed to Usenet; I see at
least gnu.gcc.announce, gnu.gcc.bug, and gnu.gcc.help on my server.
Sorry, you think *what* is the appropriate response?
Very often, the most appropriate response is simply to RTFM.
There's not much I can do about that. If you find something in the
standard unclear, especially if you provide improved wording,
comp.std.c would be the place to post. But remember that the standard
isn't intended to be a tutorial (neither is H&S5, but it's a friendly
reference than the standard is). But if you have trouble
understanding something in the standard, this is the place to ask
(since you'd be asking about the C language as described by the
standard, rather than about the standard itself as a document).
George said:What does Keith mean with:
%- He probably is. Why are you skeptical? The functions whose names
%- start with 'v' take an argument of type va_list.
Keith said:.... snip ...
There's not much I can do about that. If you find something in
the standard unclear, especially if you provide improved wording,
comp.std.c would be the place to post. But remember that the
standard isn't intended to be a tutorial (neither is H&S5, but
it's a friendly reference than the standard is). But if you have
trouble understanding something in the standard, this is the
place to ask (since you'd be asking about the C language as
described by the standard, rather than about the standard itself
as a document).
George said:Keith Thompson wrote:
.... snip ...
What I can't figure out is how to "post" to a mailing list. I
change my e-mail approximately every five months. I would *much
rather* have a news solution as opposed to an e-mail soln.
Ian said:I was referring to Unix man pages. I don't know how people can
work (especially without internet connectivity) on a platform
without "man".
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.