I will show you mine, if you will show me yours!
It's a little touchy - which is why we have round up functions in C, built in. You CAN do it yourself, and it's a great exercise to do so, but I'm not clear whether you are supposed to be doing the rounding of the number manually, or should be using the built in functions.
My post presumed that you had to round the real number at six significant figures manually, is that correct?
A better description, might be:
I used fgets() to get the whole line of text into a single string, Then "walked" the string using a for loop. If one of the char's in the string is a '.', then you have a real number, so backup the index (don't use a pointer, they're just more difficult for beginners, use the array[index] [which should be a different variable-I used i to go forward, and j to back up]), using a while loop, until you get back to the last space char, before the decimal point.
Now sscanf(array+j), with a real number format (I used double). Use a %.6 format so you can get only the right amount of digits into your variable. I divided the real number up into it's ordinal and mantissa, but that appears unnecessary. I'll look at it again when I get some time later today.
Then round the number. I used modulo 10 to get the difference between the last digit, and 0, and if the sixth significant digit was > 4, I rounded upward by adding the (10 -difference). If it was less, I subtracted the modulo 10 number.
Then I "peeled" off the digits from the real number, into a second string "real[40]", using a while (number>0) digit = number % 10+'0', and then putting the digit into the string real[]. Then dividing the real number, by 10, to get rid of that digit.
After I had all the digits from the real number, put into the real[] char array, I added an end of string char: '\0' to the end of it, and then strcpy()'d it back into the original array, right back where it came from - since I still had the variable with the index of the "backup" j value.
Then I overwrote the end of string char, that strcpy() needed, with a comma, to restore the original string of the whole line of text. You have to do this, "blind" since you can't see the '\0' char on the display of the string, but it's there. If you don't remove the extra '\0' you added, and try to print the string, you will see that the string of the entire line of data, has been truncated, at that point.
Then the string is ready to be written out to the output file. If there was no real number, then nothing will have been changed in the line of text, but it all has to be copied into a second file -- and then the original file needs to be deleted, and the second file renamed with the original file's name.