I need to modify a data file consisting of a table of numbers (specifically, I need to "de-modulate" each column - that is, undo a modulation operation). Unfortunately, throughout the table there are missing numbers corresponding to bad data or instrument failure. Even more unfortunately, ordinary whitespace is used for these missing points. In other words, something like this:
I need to first read the data into a regular array of integers. Unfortunately, even when I use width format specifiers in scanf() such as "%4d", it just skips right over the whitespace, and reads data from column 3 into column 2 if there's no data in column 2. This isn't what I want - if there's whitespace in the position, I don't want the program to read anything at all into the appropriate position in the array (that is, leave the number in column 2 unchanged) but still advance to the next position in the output array so that data from column 3 ends up in column 3 where it belongs. (Even better would be reading a special character into column 2.)Code:100 94 1 35 23 15 97 -6 41 29 21 90 -19 54 28 88 -28 60 31 35 89 -33 67 37 47
Is there any easy way to do this? Or am I going to have to read each character individually and do all the processing myself?