Deutsch   English   Français   Italiano  
<v4l7np$3m349$2@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: Whaddaya think?
Date: Sun, 16 Jun 2024 00:22:34 +0100
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <v4l7np$3m349$2@dont-email.me>
References: <666ded36$0$958$882e4bbb@reader.netnews.com>
 <87sexdx3s1.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 16 Jun 2024 01:22:33 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="48e70c5b8227fe18cdef471a005ffbe8";
	logging-data="3869833"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18qAmMPifEG5qSyaLImF8ie"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:/4U8yiGqlBrF0g/PxWYrna3/iXU=
Content-Language: en-GB
In-Reply-To: <87sexdx3s1.fsf@bsb.me.uk>
Bytes: 1967

On 15/06/2024 23:03, Ben Bacarisse wrote:
> DFS <nospam@dfs.com> writes:
> 
>> I want to read numbers in from a file, say:
>>
>> 47 185 99 74 202 118 78 203 264 207 19 17 34 167 148 54 297 271 118 245 294
>> 188 140 134 251 188 236 160 48 189 228 94 74 27 168 275 144 245 178 108 152
>> 197 125 185 63 272 239 60 242 56 4 235 244 144 69 195 32 4 54 79 193 282
>> 173 267 8 40 241 152 285 119 259 136 15 83 21 78 55 259 137 297 15 141 232
>> 259 285 300 153 16 4 207 95 197 188 267 164 195 7 104 47 291
>>
>>
>> This code:
>> 1 opens the file
>> 2 fscanf thru the file to count the number of data points
>> 3 allocate memory
>> 4 rewind and fscanf again to add the data to the int array
>>
>> Any issues with this method?
> 
> There are two issues: (1) you end up with a program that can't be
> "piped" to (because the input can't be rewound), and (2) the file might
> change between counting and reading.

It might change even while you're reading it once.