473,386 Members | 1,674 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.

fscanf

I'm doing something wrong and all I know to do is turn to clc. I have a
text file containing 2 doubles separated by a tab.

..26 0

Is the text. I want to read the two double and printf them out. Here's my
file.

#include <stdio.h>

int main() {
FILE *fp;
double x,y;
fp=fopen("zo","r"); /*error checking out for brevity */
fscanf(fp,"%.2f\t%.2f",&string);
fclose(fp);
printf("%.2f%.2f",x,y);
}

All I get is garbage that is contained in x and y. For whatever simple
reason that is beyond me evidently I can't read and printf out to stdin from
this text file. I don't think fread is really necessary.

Bill
Aug 17 '08 #1
42 3730
On Aug 18, 2:39 am, "Bill Cunningham" <nos...@nspam.comwrote:
I'm doing something wrong and all I know to do is turn to clc. I have a
text file containing 2 doubles separated by a tab.

.26 0

Is the text. I want to read the two double and printf them out. Here's my
file.

#include <stdio.h>

int main() {
FILE *fp;
double x,y;
fp=fopen("zo","r"); /*error checking out for brevity */
fscanf(fp,"%.2f\t%.2f",&string);
fclose(fp);
printf("%.2f%.2f",x,y);

}

All I get is garbage that is contained in x and y. For whatever simple
reason that is beyond me evidently I can't read and printf out to stdin from
this text file. I don't think fread is really necessary.
You're a liar, Bill. That code does not compile, so it's impossible
for you to get anything out of executing this program.
Aug 17 '08 #2
On Sun, 17 Aug 2008 23:39:25 +0000, "Bill Cunningham" <no****@nspam.com>
wrote:
I'm doing something wrong and all I know to do is turn to clc. I have a
text file containing 2 doubles separated by a tab.

.26 0

Is the text. I want to read the two double and printf them out. Here's
my file.
<snipped code>

Please post the *actual* code that you used to compile and generate the
executable that caused garbage to be printed. The code you posted will
not compile.

- Anand

Aug 17 '08 #3

"Anand Hariharan" <zn********************@tznvy.pbzwrote in message
news:g8**********@aioe.org...
Please post the *actual* code that you used to compile and generate the
executable that caused garbage to be printed. The code you posted will
not compile.
Ok I did write this on the fly. I will look again at the actual code.

Bill
Aug 18 '08 #4

"Bill Cunningham" <no****@nspam.comwrote in message
news:yx3qk.131$w51.17@trnddc01...
Ok I did write this on the fly. I will look again at the actual code.
#include <stdio.h>

int main() {
FILE *fp;
double x,y;
fp=fopen("zo","a");
fscanf(fp,"%.2f\t%.2f",&x,&y);
fclose(fp);
printf("%.2f\t%.2f",x,y);
}

Now this compiled for me with the results 0.00 and 4.87. Not the text
from the file called "zo". The only real difference here is the text mode is
append and not read.

Bill
Aug 18 '08 #5
Bill Cunningham wrote:
"Bill Cunningham" <no****@nspam.comwrote in message
news:yx3qk.131$w51.17@trnddc01...
>Ok I did write this on the fly. I will look again at the actual code.
#include <stdio.h>

int main() {
FILE *fp;
double x,y;
fp=fopen("zo","a");
fscanf(fp,"%.2f\t%.2f",&x,&y);
fclose(fp);
printf("%.2f\t%.2f",x,y);
}

Now this compiled for me with the results 0.00 and 4.87. Not the text
from the file called "zo". The only real difference here is the text mode is
append and not read.
So what does your documentation well you about append mode?

--
Ian Collins.
Aug 18 '08 #6

"Ian Collins" <ia******@hotmail.comwrote in message
news:6g************@mid.individual.net...
So what does your documentation well you about append mode?
It just says append is a possible mode with a+ also which is append-read
mode. Plus this book tells me that garbage about using t if I want for text
mode. I know that's not portable stdc.
http://www.cppreference.com/stdio/fopen.html

Is my main online reference. I've been thinking my trouble is in fscanf. It
might be in fopen's mode.

Bill

Aug 18 '08 #7
Bill Cunningham wrote:
"Ian Collins" <ia******@hotmail.comwrote in message
news:6g************@mid.individual.net...
>So what does your documentation well you about append mode?
It just says append is a possible mode with a+ also which is append-read
mode. Plus this book tells me that garbage about using t if I want for text
mode. I know that's not portable stdc.
http://www.cppreference.com/stdio/fopen.html

Is my main online reference.
Well it's a piss-poor one if that page is anything to go by. I suggest
you look up the definition of "append"

--
Ian Collins.
Aug 18 '08 #8
Bill Cunningham wrote:
"Ian Collins" <ia******@hotmail.comwrote in message
news:6g************@mid.individual.net...
>So what does your documentation well you about append mode?
It just says append is a possible mode with a+ also which is append-read
mode. Plus this book tells me that garbage about using t if I want for text
mode. I know that's not portable stdc.
http://www.cppreference.com/stdio/fopen.html

Is my main online reference. I've been thinking my trouble is in fscanf. It
might be in fopen's mode.

Bill
http://linux.die.net/man/3/fopen

"The argument mode points to a string beginning with one of the following
sequences (Additional characters may follow these sequences.):

a Open for appending (writing at end of file). The file is created if
it does not exist. The stream is positioned at the end of the file. <---- yikes

"

http://linux.die.net/man/3/fscanf

"Return Value

These functions return the number of input items successfully matched and assigned,
which can be fewer than provided for, or even zero in the event of an early matching
failure.

The value EOF is returned if the end of input is reached before either the first
successful conversion or a matching failure occurs. EOF is also returned if a read
error occurs, in which case the error indicator for the stream (see ferror(3)) is
set, and errno is set indicate the error."

Defensive programming, means checking the values returned by things like fscanf.
Wouldn't you be curious, whether fscanf converted zero, one, or two items ? If the
answer is not two, then X or Y could contain bogus information. And if an end of
file was encountered, you'd probably want to know about that also. There are many
possible outcomes, when handling file I/O.

Paul
Aug 18 '08 #9

"Paul" <no****@needed.comwrote in message news:g8**********@aioe.org...

[snip]
Defensive programming, means checking the values returned by things like
fscanf.
Wouldn't you be curious, whether fscanf converted zero, one, or two items
? If the
answer is not two, then X or Y could contain bogus information. And if an
end of
file was encountered, you'd probably want to know about that also. There
are many
possible outcomes, when handling file I/O.

Paul
Like this you mean?

fscanf(fp,"%.2f\t%.2f",&x,&y);
if (fp==EOF)
puts("fscanf error");
Bill
Aug 18 '08 #10
On Mon, 18 Aug 2008 00:49:03 GMT, "Bill Cunningham" <no****@nspam.com>
wrote:
>
"Bill Cunningham" <no****@nspam.comwrote in message
news:yx3qk.131$w51.17@trnddc01...
>Ok I did write this on the fly. I will look again at the actual code.
#include <stdio.h>

int main() {
FILE *fp;
double x,y;
fp=fopen("zo","a");
Are you reading from or writing to fp?
fscanf(fp,"%.2f\t%.2f",&x,&y);
Do you have a reference that describes fscanf? Did you read it? Does
fscanf allow "." inside a conversion specification? Is "f" the
correct conversion specifier for a double?
fclose(fp);
printf("%.2f\t%.2f",x,y);
}

Now this compiled for me with the results 0.00 and 4.87. Not the text
What does the input file look like?
>from the file called "zo". The only real difference here is the text mode is
Difference from what?
>append and not read.
And you chose this mode why?

--
Remove del for email
Aug 18 '08 #11
Bill Cunningham wrote:
"Paul" <no****@needed.comwrote in message news:g8**********@aioe.org...

[snip]
>Defensive programming, means checking the values returned by things like
fscanf.
Wouldn't you be curious, whether fscanf converted zero, one, or two items
? If the
answer is not two, then X or Y could contain bogus information. And if an
end of
file was encountered, you'd probably want to know about that also. There
are many
possible outcomes, when handling file I/O.

Paul

Like this you mean?

fscanf(fp,"%.2f\t%.2f",&x,&y);
if (fp==EOF)
puts("fscanf error");
Bill

fscanf also returns an integer value. You haven't
taken advantage of the integer it returns.

returned_value = fscanf(fp,"%.2f\t%.2f",&x,&y)

The manual page says the returned_value can tell you some things
about how things went, when the fscanf ran. You could check
returned_value, to see how many arguments it got.

This is not defensive programming, but you could
do something like use "printf" to print the value
of the integer "returned_value", and see whether it
is the value you expected. If the value printed was 2,
then you'd know you got two conversions, so both "x"
and "y" got loaded with goodies.

Try defining an integer called return_value, and
see what is coming back from fscanf. Use printf
to print out the value of "returned_value".

Once you've figured out what went wrong, you can
add conditional statements to your program, to
protect it against invalid input or unexpected
results like EOF.

In your next posting, you can tell us what printf printed,
and your interpretation of what it means.

Paul
Aug 18 '08 #12
Paul wrote:

<sound advice>

Don't spoon feed the troll :)

--
Ian Collins.
Aug 18 '08 #13
"Bill Cunningham" <no****@nspam.comwrites:
"Bill Cunningham" <no****@nspam.comwrote in message
news:yx3qk.131$w51.17@trnddc01...
>Ok I did write this on the fly. I will look again at the actual code.
#include <stdio.h>

int main() {
FILE *fp;
double x,y;
fp=fopen("zo","a");
fscanf(fp,"%.2f\t%.2f",&x,&y);
fclose(fp);
printf("%.2f\t%.2f",x,y);
}

Now this compiled for me with the results 0.00 and 4.87. Not the text
from the file called "zo". The only real difference here is the text mode is
append and not read.
No, there at least two real differences. One is that you're not
referring to an undeclared variable called "string". The other is
that you change the mode for fopen from "r" (which would have been
correct) to "a" (which makes no sense).

"a" is append mode; it means you want to write new data to the end of
an existing file. Why would you use append mode when you want to
*read* from the file?

BTW, do you expect us to *guess* what's in your "zo" file?

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Aug 18 '08 #14
"Bill Cunningham" <no****@nspam.comwrites:
[...]
Like this you mean?

fscanf(fp,"%.2f\t%.2f",&x,&y);
if (fp==EOF)
puts("fscanf error");
No.

What type is fp? What type is EOF? What makes you think that
comparing fp to EOF is meaningful?

Stop guessing. Get a decent reference and READ IT.

If you have a copy of K&R2, my advice is to use it as your one and
only reference. Don't waste your time with cvppreference.com; it's
for C++.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Aug 18 '08 #15
On Aug 18, 5:23 am, Keith Thompson <ks...@mib.orgwrote:
"Bill Cunningham" <nos...@nspam.comwrites:

[...]
Like this you mean?
fscanf(fp,"%.2f\t%.2f",&x,&y);
if (fp==EOF)
puts("fscanf error");

No.

What type is fp? What type is EOF? What makes you think that
comparing fp to EOF is meaningful?

Stop guessing. Get a decent reference and READ IT.

If you have a copy of K&R2, my advice is to use it as your one and
only reference. Don't waste your time with cvppreference.com; it's
for C++.
correction (typo): cppreference.com not cVppreference.com.
Also, I'm not sure what cppreference.com is for, but it does not seem
to be an appropriate resource for C++, so please don't suggest it.
Just... don't waste time with cppreference :-)
Aug 18 '08 #16
vi******@gmail.com writes:
On Aug 18, 5:23 am, Keith Thompson <ks...@mib.orgwrote:
[...]
>Stop guessing. Get a decent reference and READ IT.

If you have a copy of K&R2, my advice is to use it as your one and
only reference. Don't waste your time with cvppreference.com; it's
for C++.

correction (typo): cppreference.com not cVppreference.com.
Whoops, thanks for the correction.

[...]

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Aug 18 '08 #17
On 18 Aug, 00:39, "Bill Cunningham" <nos...@nspam.comwrote:
* * I'm doing something wrong and all I know to do is turn to clc. I have a
text file containing 2 doubles separated by a tab.

.26 * *0

Is the text. I want to read the two double and printf them out. Here's my
file.

#include <stdio.h>

int main() {
* * * FILE *fp;
* * * double x,y;
* * * *fp=fopen("zo","r"); /*error checking out for brevity */
* * * *fscanf(fp,"%.2f\t%.2f",&string);
* * * *fclose(fp);
* * * *printf("%.2f%.2f",x,y);

}

All I get is garbage that is contained in x and y. For whatever simple
reason that is beyond me evidently I can't read and printf out to stdin from
this text file. I don't think fread is really necessary.
0. fix your layout
1. post your code
2. post your input data
3. post your output
4. explain why you don't like 3
5. check return values
6. RTFM
7. don't guess (see 6)

--
Nick Keighley
Aug 18 '08 #18

"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
BTW, do you expect us to *guess* what's in your "zo" file?
No Keith I've already said it contains,

..26 0.00

In using the code I posted before I got...

0.00 4.87

If I would've set xand y to 0 that is what would've been printed with
printf. I see the fopen mode I should've used was "r". I'll keep working
with it.

Bill
Aug 18 '08 #19

"Paul" <no****@needed.comwrote in message news:g8**********@aioe.org...

[snip]
>
fscanf also returns an integer value. You haven't
taken advantage of the integer it returns.

returned_value = fscanf(fp,"%.2f\t%.2f",&x,&y)

The manual page says the returned_value can tell you some things
about how things went, when the fscanf ran. You could check
returned_value, to see how many arguments it got.

This is not defensive programming, but you could
do something like use "printf" to print the value
of the integer "returned_value", and see whether it
is the value you expected. If the value printed was 2,
then you'd know you got two conversions, so both "x"
and "y" got loaded with goodies.

Try defining an integer called return_value, and
see what is coming back from fscanf. Use printf
to print out the value of "returned_value".

Once you've figured out what went wrong, you can
add conditional statements to your program, to
protect it against invalid input or unexpected
results like EOF.

In your next posting, you can tell us what printf printed,
and your interpretation of what it means.

Paul
Ok I'll try it. I'm not used to using the *scanf family. I usually use fgets
or fgetc.

Bill
Aug 18 '08 #20

"Bill Cunningham" <no****@nspam.comwrote in message
news:zulqk.194$p72.57@trnddc05...
Ok I'll try it. I'm not used to using the *scanf family. I usually use
fgets or fgetc.

Here's the code re-written a little but the results are the same.

#include <stdio.h>
#include <stdlib.h>

int main()
{
FILE *fp;
double x, y;
int rv;
char *string = "%.2f\t%.2f";
if ((fp = fopen("zo", "r")) == NULL) {
puts("open error");
exit(-1);
}
rv = fscanf(fp, string, &x, &y);
fclose(fp);
printf("%i\n", rv);
printf(string, x, y);
}

The the rv that catches the return value of fscanf reported 0. The same
garbage was printed from the x and y variables.

0.00 4.87

Bill
Aug 19 '08 #21

"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
vi******@gmail.com writes:
>On Aug 18, 5:23 am, Keith Thompson <ks...@mib.orgwrote:
>correction (typo): cppreference.com not cVppreference.com.

Whoops, thanks for the correction.
Keith I hope this posts with no header problem above. I have k&r2. I use
the www.cppreference.com C section to look up return values mainly. I find
linux's man pages very vague IMO on my linux anyway, that is old.

Bill
Aug 19 '08 #22
"Bill Cunningham" <no****@nspam.comwrites:
"Bill Cunningham" <no****@nspam.comwrote in message
news:zulqk.194$p72.57@trnddc05...
>Ok I'll try it. I'm not used to using the *scanf family. I usually use
fgets or fgetc.

Here's the code re-written a little but the results are the same.
<snip>

Compare with:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
FILE *fp;
double x, y;
int rv;
if ((fp = fopen("zo", "r")) == NULL) {
perror("open error");
return EXIT_FAILURE;
}
rv = fscanf(fp, "%lf\t%lf", &x, &y);
fclose(fp);
printf("%i\n", rv);
printf("%.2f\t%.2f\n", x, y);
return EXIT_SUCCESS;
}

fscanf formats are not the same as printf formats.

--
Ben.
Aug 19 '08 #23
Bill Cunningham said:
I have k&r2.
Great.
I use the www.cppreference.com C section to look up return values mainly.
I suggest you stop doing that. You have a much more authoritative reference
available to you: K&R2. Use it.

--
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
Aug 19 '08 #24

"Bill Cunningham" <no****@nspam.comwrote in message
news:yYoqk.212$lf2.25@trnddc07...
??

Who are you addressing Barry?

Bill
If you are making a comment to simply say something I'm not listening.
If you want to help and are saying something critical I'm listening.

There are 2 main people on usenet. The one who asks for help and those
who want to help. Then there's noise. Meaningless, helpless, nonsense.

Bill
Aug 19 '08 #25

"Ben Bacarisse" <be********@bsb.me.ukwrote in message
news:87************@bsb.me.uk...
fscanf formats are not the same as printf formats.
I hadn't noticed that Ben for some reason. So what I should do is use
%lf or the float type for x and y then.

Now I feel silly for asking a question like this but I was really stuck.
But isn't %f still a float conversion in *scanf ? The program I wrote to
print the file "zo" and the text it contains uses fprintf %f conversion for
2 doubles. Here's a snippet...

double x,y;
x=strtod(argv[1],NULL);
y=strtod(argv[2],NULL);
fprintf(argv[3],"%.2f\t%.2f",x,y);

Float conversion can be used on doubles.
But I guess not in fscanf.

Bill


Aug 19 '08 #26
Bill Cunningham wrote:
"Bill Cunningham" <no****@nspam.comwrote in message
news:zulqk.194$p72.57@trnddc05...
>Ok I'll try it. I'm not used to using the *scanf family. I usually use
fgets or fgetc.


Here's the code re-written a little but the results are the same.

#include <stdio.h>
#include <stdlib.h>

int main()
{
FILE *fp;
double x, y;
int rv;
char *string = "%.2f\t%.2f";
if ((fp = fopen("zo", "r")) == NULL) {
puts("open error");
exit(-1);
}
rv = fscanf(fp, string, &x, &y);
fclose(fp);
printf("%i\n", rv);
printf(string, x, y);
}

The the rv that catches the return value of fscanf reported 0. The same
garbage was printed from the x and y variables.

0.00 4.87

Bill

So now you know that zero parameters were converted by fscanf.
X and Y cannot have good values, because no conversion was done.

This guy wrote a similar example, but even he did not consider that
fscanf might convert zero items. He is checking for EOF with
feof(file). If you had continued to use the "append" mode for
your input file, then inserting an feof(file) check might
have indicated a problem (i.e. already at the end of the file).

(second example down...)
http://irc.essex.ac.uk/www.iota-six....nf_fprintf.asp

Since you changed to "r" mode for opening the file, then the
file pointer is probably not at the end of the file any more.

And that leaves the "string" specification as being the dodgy bit.
Try some other specifications first. Try converting just one
number with "%f" and work from there. This stuff looks tricky.

See PDF page 299, for a few examples of fscanf usage. Or search for
the string "25 54.32E-1 thompson" which is input to the first example.

http://www.open-std.org/jtc1/sc22/wg...docs/n1124.pdf

I was amazed at all the stuff I could find.

Paul
Aug 19 '08 #27
"Bill Cunningham" <no****@nspam.comwrites:
"Ben Bacarisse" <be********@bsb.me.ukwrote in message
news:87************@bsb.me.uk...
>fscanf formats are not the same as printf formats.
I hadn't noticed that Ben for some reason. So what I should do is use
%lf or the float type for x and y then.
No. You really do need a reference manual. I used lf because you
don't have floats. For scanf, %lf expects a pointer to a double (as
you have).
Now I feel silly for asking a question like this but I was really stuck.
But isn't %f still a float conversion in *scanf ?
Yes it is. It would work if you had float variables but you don't,
you have doubles.
The program I wrote to
print the file "zo" and the text it contains uses fprintf %f conversion for
2 doubles. Here's a snippet...

double x,y;
x=strtod(argv[1],NULL);
y=strtod(argv[2],NULL);
fprintf(argv[3],"%.2f\t%.2f",x,y);

Float conversion can be used on doubles.
By "float conversion" do you mean %f? If so, then it *requires* a
double in the printf. The trick is that floats get converted to
double in a call to printf anyway so there is little danger of getting
it wrong.

--
Ben.
Aug 19 '08 #28
"Bill Cunningham" <no****@nspam.comwrites:
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
>BTW, do you expect us to *guess* what's in your "zo" file?

No Keith I've already said it contains,

.26 0.00
So you did.

However, you only mentioned that in your original article, in which
you posted non-compilable code. I didn't take the time to go back and
re-read it.

[snip]

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Aug 19 '08 #29
"Bill Cunningham" <no****@nspam.comwrites:
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
>vi******@gmail.com writes:
>>On Aug 18, 5:23 am, Keith Thompson <ks...@mib.orgwrote:

>>correction (typo): cppreference.com not cVppreference.com.

Whoops, thanks for the correction.

Keith I hope this posts with no header problem above. I have
k&r2. I use the www.cppreference.com C section to look up return
values mainly. I find linux's man pages very vague IMO on my linux
anyway, that is old.
As I recall, K&R2's reference section does a perfectly good job of
describing return types for standard library functions.

I reiterate my advice: Stop using any reference materials other than
K&R2. Well, not quite; the comp.lang.c FAQ is also an excellent and
reliable resource. If those two resources together are not
sufficiently helpful, then ask here -- but *only* after you've
carefully checked the types and meanings of any arguments and return
types for all standard functions you're calling.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Aug 19 '08 #30

"Paul" <no****@needed.comwrote in message news:g8**********@aioe.org...
http://www.open-std.org/jtc1/sc22/wg...docs/n1124.pdf

I was amazed at all the stuff I could find.
Ok I see this is the document eeryone looks at when they say "The
standard says..." I was just going to inquire about that. I read the other
day in k&r2 printf wasn't part of the standard. I'm not quite sure what it
meant but that's what it said.

Bill
Aug 19 '08 #31
Bill Cunningham wrote:

[ ... ]
I read the other day in k&r2 printf wasn't part of the standard.
[ ...]

On which page?

Aug 19 '08 #32
In article <w8Fqk.299$UX.162@trnddc03>, "Bill Cunningham" <no****@nspam.comwrote:
>I read the other day in k&r2 printf wasn't part of the standard.
You read WHAT?
>I'm not quite sure what it
meant but that's what it said.
I am quite sure that is NOT what it said.
Aug 19 '08 #33

"santosh" <sa*********@gmail.comwrote in message
news:g8**********@registered.motzarella.org...
On which page?
Ok maybe the word standard is incorrect but here,

page 11 "...printf is not part of the C language; there is no input or
output defined by C itself."

Maybe there's a difference in "standard" and "C language" ?

Bill
Aug 19 '08 #34
On 2008-08-19, Bill Cunningham <no****@nspam.comwrote:
>
"santosh" <sa*********@gmail.comwrote in message
news:g8**********@registered.motzarella.org...
>On which page?

Ok maybe the word standard is incorrect but here,

page 11 "...printf is not part of the C language; there is no input or
output defined by C itself."

Maybe there's a difference in "standard" and "C language" ?
This seems like mincing words to me - but what K&R meant was that
the "C Language", defined I guess by reserved keywords, had no
input or output.

printf() is a function, which is part of the standard C library.
It's not a *keyword*, so technically it isn't part of the C
language.

--
Andrew Poelstra ap*******@wpsoftware.com
To email me, use the above email addresss with .com set to .net
Aug 19 '08 #35
Bill Cunningham wrote:
"santosh" <sa*********@gmail.comwrote in message
news:g8**********@registered.motzarella.org...
On which page?

Ok maybe the word standard is incorrect but here,

page 11 "...printf is not part of the C language; there is no input or
output defined by C itself."

Maybe there's a difference in "standard" and "C language" ?
The C standard describes both the C language (section 6) and the C
standard library (section 7).
Aug 19 '08 #36
"Bill Cunningham" <no****@nspam.comwrites:
"santosh" <sa*********@gmail.comwrote in message
news:g8**********@registered.motzarella.org...
>On which page?

Ok maybe the word standard is incorrect but here,

page 11 "...printf is not part of the C language; there is no input or
output defined by C itself."

Maybe there's a difference in "standard" and "C language" ?
The C standard describes the "language" in section 6 and the "library"
in section 7. Both are part of the standard.

The term "language" is also used to refer to the whole of what the
standard describes, including the library. It's ambiguous, but in
practice it's not usually too much of a problem.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Aug 19 '08 #37
On Aug 19, 4:06 am, "Bill Cunningham" <nos...@nspam.comwrote:
"Keith Thompson" <ks...@mib.orgwrote in message

news:ln************@nuthaus.mib.org...
vipps...@gmail.com writes:
On Aug 18, 5:23 am, Keith Thompson <ks...@mib.orgwrote:
correction (typo): cppreference.com not cVppreference.com.
Whoops, thanks for the correction.

Keith I hope this posts with no header problem above. I have k&r2. I use
the www.cppreference.com C section to look up return values mainly. I find
linux's man pages very vague IMO on my linux anyway, that is old.
I've never written that, stop lying, liar.
Aug 19 '08 #38
vi******@gmail.com writes:
On Aug 19, 4:06 am, "Bill Cunningham" <nos...@nspam.comwrote:
>"Keith Thompson" <ks...@mib.orgwrote in message

news:ln************@nuthaus.mib.org...
vipps...@gmail.com writes:
On Aug 18, 5:23 am, Keith Thompson <ks...@mib.orgwrote:
correction (typo): cppreference.com not cVppreference.com.
Whoops, thanks for the correction.

Keith I hope this posts with no header problem above. I have k&r2. I use
the www.cppreference.com C section to look up return values mainly. I find
linux's man pages very vague IMO on my linux anyway, that is old.

I've never written that, stop lying, liar.
In message
<23**********************************@k13g2000hse. googlegroups.com>,
available at
<http://groups.google.com/group/comp.lang.c/msg/0f9771c72501209b>,
you, vippstar, did write:

correction (typo): cppreference.com not cVppreference.com.

In message <M0pqk.213$lf2.146@trnddc07>, available at
<http://groups.google.com/group/comp.lang.c/msg/a7ae6bac42f2ebf4>,
Bill Cunningham correctly quoted what you wrote and correctly
attributed it to you; the number of prefixed ">" characters was even
correct. (He left in an extraneous attibution line with my name in
it, though he had snipped what I had written; I consider that a minor
error not worth complaining about, but I mention it here for
completeness.)

Before you call someone a liar, you need to be *very* sure that you're
right, that the other person's statement is false, and that the
falsehood was deliberate.

In my opinion, you owe Bill Cunningham an apology.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Aug 19 '08 #39
vipps...@gmail.com wrote:
On Aug 19, 4:06 am, "Bill Cunningham" <nos...@nspam.comwrote:
"Keith Thompson" <ks...@mib.orgwrote in message

news:ln************@nuthaus.mib.org...
vipps...@gmail.com writes:
>On Aug 18, 5:23 am, Keith Thompson <ks...@mib.orgwrote:
>correction (typo): cppreference.com not cVppreference.com.
Whoops, thanks for the correction.
Keith I hope this posts with no header problem above. I have k&r2. I use
the www.cppreference.com C section to look up return values mainly. I find
linux's man pages very vague IMO on my linux anyway, that is old.

I've never written that, stop lying, liar.
The only lines that the cited message attributes to you are the ones
that in this message start with the prefix
" >>"; in the message you're responding to, they had a prefix of
">>".

According to Google groups, those lines were indeed written by you, in
the following message: <http://groups.google.com/group/comp.lang.c/msg/
0f9771c72501209b>
Has someone else been posting using your name?

Furthermore, I can't figure out why you'd object so strongly to having
those lines attributed to you. They show you finding a valid error,
which Keith acknowledged gratefully. It puts you in a pretty good
light, I would think. Therefore, even if they were actually written by
someone else, I would only expect you to be confused by the mis-
attribution, not angry about it. Am I missing something?
Aug 19 '08 #40
On Aug 20, 2:01 am, Keith Thompson <ks...@mib.orgwrote:
vipps...@gmail.com writes:
On Aug 19, 4:06 am, "Bill Cunningham" <nos...@nspam.comwrote:
"Keith Thompson" <ks...@mib.orgwrote in message
>news:ln************@nuthaus.mib.org...
vipps...@gmail.com writes:
On Aug 18, 5:23 am, Keith Thompson <ks...@mib.orgwrote:
correction (typo): cppreference.com not cVppreference.com.
Whoops, thanks for the correction.
Keith I hope this posts with no header problem above. I have k&r2. I use
thewww.cppreference.comC section to look up return values mainly. I find
linux's man pages very vague IMO on my linux anyway, that is old.
I've never written that, stop lying, liar.

In message
<23ed5e23-0d31-4c1d-a28c-eacb1738f...@k13g2000hse.googlegroups.com>,
available at
<http://groups.google.com/group/comp.lang.c/msg/0f9771c72501209b>,
you, vippstar, did write:

correction (typo): cppreference.com not cVppreference.com.

In message <M0pqk.213$lf2.146@trnddc07>, available at
<http://groups.google.com/group/comp.lang.c/msg/a7ae6bac42f2ebf4>,
Bill Cunningham correctly quoted what you wrote and correctly
attributed it to you; the number of prefixed ">" characters was even
correct. (He left in an extraneous attibution line with my name in
it, though he had snipped what I had written; I consider that a minor
error not worth complaining about, but I mention it here for
completeness.)

Before you call someone a liar, you need to be *very* sure that you're
right, that the other person's statement is false, and that the
falsehood was deliberate.

In my opinion, you owe Bill Cunningham an apology.
You're absolutely correct. The format of the message confused me. I
apologise to Bill Cunningham.
I got angry because IMHO Bill is a troll and I thought he reordered
the quotes (or something like that).

Aug 19 '08 #41
On Aug 20, 2:11 am, jameskuy...@verizon.net wrote:
vipps...@gmail.com wrote:
<snip>
According to Google groups, those lines were indeed written by you, in
the following message: <http://groups.google.com/group/comp.lang.c/msg/
0f9771c72501209b>
Has someone else been posting using your name?
I don't think so. That particular message was written and posted by
me.
Furthermore, I can't figure out why you'd object so strongly to having
those lines attributed to you. They show you finding a valid error,
which Keith acknowledged gratefully. It puts you in a pretty good
light, I would think. Therefore, even if they were actually written by
someone else, I would only expect you to be confused by the mis-
attribution, not angry about it. Am I missing something?
It was me who was missing something. Confusion lead to anger. See my
messsage to mr Thompson for complete explanation.
Aug 19 '08 #42
vi******@gmail.com said:
On Aug 20, 2:01 am, Keith Thompson <ks...@mib.orgwrote:
<snip>
>In my opinion, you owe Bill Cunningham an apology.

You're absolutely correct. The format of the message confused me. I
apologise to Bill Cunningham.
Handsomely done.
I got angry because IMHO Bill is a troll [...]
If you really think someone is a troll, the most important thing you can do
when reading their articles is *not get angry*.

That's (partly) what motivates trolls - they *want* to see you angry. If
Bill is a troll, perhaps he's the same, too.

If you can't deal calmly with the likes of Twink and Riley and McCormack
and (possibly) Cunningham - or if you simply think they're complete bozos
with the apparent mental capacity of a walnut and the reading
comprehension level of a two-year-old digestive biscuit - then I recommend
that you start using a killfile.

--
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
Aug 20 '08 #43

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

Similar topics

3
by: Benedicte | last post by:
Hi, I'm getting some problems when using fscanf to read a file. This is a piece of the program code: main () { /*** Variable declaration ***/ FILE *vpfile; /*** Data file ***/
4
by: Psibur | last post by:
Hello, trying to get back into c and was having issue with reading a simple text file with an aribtrary # of lines with 3 int's per line, with the eventual purpose of putting each int into an...
7
by: Thomas Sourmail | last post by:
Hi, I hope I am missing something simple, but.. here is my problem: I need my program to check the last column of a file, as in : a b c d target ref 0 0 0 0 1 a 1 0 0 0 1.5 b 2 0 0 0 2 c
1
by: siliconwafer | last post by:
Hi All, here is one code: int main() { FILE*fp; unsigned long a; fp = fopen("my_file.txt","w+"); a = 24; fprintf(fp,"%ld",a); while(fscanf(fp,"%ld",&a) == 1) {
9
by: quyvle | last post by:
I can't seem to get this function to work correctly. I'm wondering if anyone could help me out with this. So I'm using the fscanf function to read the input stream and store each string in the...
9
by: kvnsmnsn | last post by:
Over the course of my career I've transitioned from an Ada programmer (am I dating myself?) to a C programmer to a Java programmer and now back to a C programmer with the job I've currently...
37
by: PeterOut | last post by:
I am using MS Visual C++ 6.0 on Windows XP 5.1 (SP2). I am not sure if this is a C, C++ or MS issue but fscanf has been randomly hanging on me. I make the call hundreds, if not thousands, of...
59
by: David Mathog | last post by:
Apologies if this is in the FAQ. I looked, but didn't find it. In a particular program the input read from a file is supposed to be: + 100 200 name1 - 101 201 name2 It is parsed by reading...
1
momotaro
by: momotaro | last post by:
I have a small problem with the last fscanf in this function...every thing is logic in there but can't find the problem... plz help node *BuildGraph() { int range, vehicules, i, j,...
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: 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
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
Oralloy
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,...
0
jinu1996
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...

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.