Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Please help -- cannot read double data from file into array |
| Date | 2015-11-17 13:28 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <87si44zre2.fsf@bsb.me.uk> (permalink) |
| References | <bb0cef7b-950a-4fcb-a7c9-2a8fbe558cd7@googlegroups.com> <n2f580$g5i$1@dont-email.me> |
BartC <bc@freeuk.com> writes:
> On 17/11/2015 08:39, dakupoto@gmail.com wrote:
<snip>
>> Could somoene please provide some hints
>> as to what might be going wrong. Thanks
>> in advance for your help.
>
> A few people are saying that you are not writing to the array properly
> within parsestring(). I can't see it myself.
That was certainly a problem, though there may have been other issues.
The two suggested fixes that I've noticed so far are to pass the right
row of indata to parsestring (from Malcolm), and pass indata as is
currently done but to use the row number that is present in the input to
store the data in the right place (from me).
> If I strip out all the irrelevant stuff, then this code that writes
> into the array the same way you do seems to give the expected results:
>
> #include <stdio.h>
>
> void parsestring(char *cp, double a[][2]);
>
> #define NUMROWS 262144
>
> FILE *fPtr = NULL;
> double indata[NUMROWS][2];
>
> void readFile(FILE *fPtr, double a[][2])
> { parsestring(&data[0], a);
> }
>
> void parsestring(char *cp, double a[][2])
> {
> a[0][0]=10.0;
> a[0][1]=20.0;
> a[1][0]=110.0;
> a[1][1]=120.0;
> a[2][0]=210.0;
> a[2][1]=220.0;
> a[3][0]=310.0;
> a[3][1]=320.0;
> }
To the OP: I think BartC is just checking that the parameters types are
correct here. Don't that this sketch as the right way to do it since it
removes your line-by-line loop and could be seen as suggesting that all
the data should be read into a single string first!
<snip>
--
Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Please help -- cannot read double data from file into array dakupoto@gmail.com - 2015-11-17 00:39 -0800
Re: Please help -- cannot read double data from file into array Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-11-17 00:54 -0800
Re: Please help -- cannot read double data from file into array gamo <gamo@telecable.es> - 2015-11-17 11:36 +0100
Re: Please help -- cannot read double data from file into array Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-17 11:04 +0000
Re: Please help -- cannot read double data from file into array Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-17 11:02 +0000
Re: Please help -- cannot read double data from file into array James Kuyper <jameskuyper@verizon.net> - 2015-11-17 06:51 -0500
Re: Please help -- cannot read double data from file into array BartC <bc@freeuk.com> - 2015-11-17 12:08 +0000
Re: Please help -- cannot read double data from file into array Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-17 13:28 +0000
Re: Please help -- cannot read double data from file into array BartC <bc@freeuk.com> - 2015-11-17 14:20 +0000
Re: Please help -- cannot read double data from file into array dakupoto@gmail.com - 2015-11-17 20:50 -0800
Re: Please help -- cannot read double data from file into array Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-18 11:22 +0000
Re: Please help -- cannot read double data from file into array BartC <bc@freeuk.com> - 2015-11-18 12:15 +0000
Re: Please help -- cannot read double data from file into array dakupoto@gmail.com - 2015-11-18 23:07 -0800
Re: Please help -- cannot read double data from file into array Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-19 10:41 +0000
Re: Please help -- cannot read double data from file into array BartC <bc@freeuk.com> - 2015-11-19 11:13 +0000
csiph-web