D
dmoran21
You can misread excellent advice as an insult if you like, but that's
your problem, not mine.
All, I apologize for my behavior...I'm just really frustrated. I
appreciate the help.
You can misread excellent advice as an insult if you like, but that's
your problem, not mine.
On Jul 6, 10:31 am, Army1987 <[email protected]> wrote:
Ok I found the version with the checks. I thought it'd be easier to
deal with getting it to run and then going back to put in the checks.
William said:A point which I addressed later in my post.
Without #including stdin, these can't work.
So it'd be #include <stdin.h>, correct?
[email protected] said:So it'd be #include <stdin.h>, correct?
Nope - typo - "stdio.h"
Look, I'm doing the best I can. Not only am I working on this, but
I've got other projects I'm working on and I'm REALLY TRYING to learn.
The insinuation that I'm not is insulting.
DON'T QUOTE SIGS. I feel justified in shouting this time.
I get most of this, but what does it mean when fscanf == 2?while (count < array_length &&
fscanf(fpin, "%ld,%f", &date[count], &precipvals[count]) == 2) {
Ok I found the version with the checks. I thought it'd be easier to
deal with getting it to run and then going back to put in the checks.
That way, you know (from the absence of such messages at runtime) what
is *not* the problem, and that can help you focus on what remains.
Nope - typo - "stdio.h"
[email protected] said:I get most of this, but what does it mean when fscanf == 2?while (count < array_length &&
fscanf(fpin, "%ld,%f", &date[count], &precipvals[count]) == 2) {
It means that two values were read, converted and stored. Your fscanf
can return 0, 1, 2 or EOF. Only in only one of these cases (2) is it
safe to do anything with the data.
It is also only safe to continue to try to read more if your got two
inputs. If fscanf returns 0, 1 the most likely reason is a format
error in the input (maybe "123;1.2" rather than "123,1.2") and trying to
get more will fail (because the ";" is still there waiting for you to
decide what to do with it). fscanf won't ever return EOF in that case
and your loop, as originally written, would never have terminated.
Here's the code; it now compiles, but seg faults when I run it. (Error
proofing will be done later)
[...]
[...]
while (fscanf(fpin, "%12s,&f", date, &pval1) == 2) {
[email protected] said:DON'T QUOTE SIGS. I feel justified in shouting this time.
Well Justified if I may add. Sorry
while (count < array_length &&
fscanf(fpin, "%ld,%f", &date[count], &precipvals[count]) == 2) {
I get most of this, but what does it mean when fscanf == 2?
From N869:
Here's the code; it now compiles, but seg faults when I run it. (Error
proofing will be done later)
(Joining the fray late)
Can I ask, just why are you doing this (in C) ?
Given that neither of you (I.e., you & your boss) are programmers, and
seem, quite rightly (and I don't mean anything the least bit negative in
saying this) have no desire to become one:
Why not do this simple task in something like AWK (or Perl or Python or
Ruby, or whatever, depending on how "au courant" you want to be; my
preference is for AWK) ?
From what I can tell, you could do this in 2 or 3 lines of AWK.
Further, AWK is available for all the usual platforms. If you're
working on Unix, it is there automatically; if Windows, you may have to
fire up a browser and execute a dozen or so mouse clicks to get it
running on your machine.
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.