Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
read from a file... Fortran or C
Name: DaveA Date: January 20, 2002 at 17:00:47 Pacific
Comment:
Hi there,
I'm trying to read data from a file that looks like this:
Into a 2D-array in either C or Fortran (preferably Fortran, and F77).
The file has 128 numbers on each row (space separated) and is 128 lines deep, so I want a 128 x 128 2D array.
Anyone have any ideas? I have made a little progress, but I don't know enough about fgets (in C) or the READ command (in F77), or about string manipulation to get my head around it.
Name: Apple Date: January 24, 2002 at 12:59:51 Pacific
Reply:
fgets will read a long of N characters UNTIL it reaches a newline (\n). IE. this will strip one line at a time from your file for the command: fgets( string, 256, fp ); assuming no lines are greater than 256 characters long.
After that, it's just a matter of picking the numbers off the front of the string and finding the next space. Pointers are your friends.
0
Response Number 2
Name: yassine Date: March 25, 2002 at 08:17:29 Pacific
Summary: I'm not too good at reading from a file either, but what is CurrentSize in your SaveToFile? The file may be so big that it takes a long time for C++ to read it all. Have you tried just reading one App...
Summary: I want to read the data from a file and execute it.Question is as shown. Can anyone provide the code for the below question. Input Description: The first line contains an integer t which is the number...
Summary: Hi M2G. But why? > newfile & setLocal EnableDelayedExpansion Only the first word in the first line of the text file is being extracted, delayed expansion is not required (?) and no file is being wri...