Thank you ever so much Salem, I understand now, much better the fgets() approach! Thanks also to Elysia for your comments!
Type: Posts; User: sirsmilealot
Thank you ever so much Salem, I understand now, much better the fgets() approach! Thanks also to Elysia for your comments!
Thanks Elysia - I'll have a go at this now.
Salem - The full text file is attached above in an earlier post though here are 10 lines in any case:
2.67 2.464
2.393 1.228
2.167 0.657...
Thanks Salem,
I tried your suggested code but this resulted in my program only reading in 1 value from the text file?! I'm really quite confused now haha!
I slotted the if/else statement into...
With all due respect, this may be "trivial" to you though I've only been programming for a few days! I do have a debugger and it runs without fail. You say they aren't initialised but I've now done...
OK - I've managed to resolve this issue, only to find another later down the line! When working out the minimum value stored within the two arrays I get an unexpected output for the first column of...
Thanks for your help Elysia - I realised it would be much easier to re-use the counter 'i' as this will have effectively 'counted' the number of elements into the array. I *think* this is problem...
If you're going to post onto these forums for help, at least think twice before submitting your code if you're worried about others "cheating". This is a public forum and not somewhere for...
Hello All,
I'm new to C programming and have been set an assignment. We are to read in float values from a text file and insert them into two arrays, then perform certain manipulations to the...
Well, thanks a lot for all your help - I'd have been stuck for hours more otherwise! I've now got to:
b) Calculate and print to screen the total and average of each column
c) Calculate and print...
Ah, I see where we're goin' with this. I only started programming in C a couple of days ago so I've a long way to go yet but already it's starting to make sense! I'm still slightly confused about how...
OK - thanks folks I now have the data into two arrays! nadroj - you mentioned it to be bad practice using feof() to control a loop, and I can now see for why as the last value stored into the array...
Thanks also nadroj. Above is the text file, the columns are seemingly only separated by a space. (Ignore the alternate line spaces).
Thanks for your reply Adak. I have tried your first suggestion but this doesn't seem to separate the columns into one array from the other. Here is a shortened version of the text file:
...
Hello All,
I'm having trouble getting this code to work. Basically, I have been given a '.txt' file with two columns of extensive float values. We have been asked to write a program that will...