Karthik Agarwal

Karthik Agarwal

  • NA
  • 748
  • 265.4k

How to find the number of top columns and columns which contains all zero's in a file?

May 11 2012 10:42 AM
I have something typical to do, and i am not sure how do that. Can someone help me out this!!!


I have data as follows from which what i should be doing in this is, if you observe the data closely top 2 lines of the data are all zero's and the bottom three lines are all zero's. This is what i need to find from the data. Suppose in this case the number of lines of data i have is 8 of which top 2 lines and bottom 3 lines are empty. I need to find the exact number of lines and the number of lines which contains all zero's in a line till it find some non zero value. Similar work should be done in the bottom of the data. Suppose if 4th line of the data below is all zero's i don't need that bcoz still there is data left over.

static DATA_T const lc38[]=
{
   0x00,0x00,0x00,0x00
  ,0x00,0x00,0x00,0x00
  ,0x00,0xA0,0x4F,0x00
  ,0x00,0x40,0xAF,0x00
  ,0x00,0x00,0xFA,0x05
  ,0x00,0x00,0x00,0x00
  ,0x00,0x00,0x00,0x00
  ,0x00,0x00,0x00,0x00
};

I know it's weird but what can i do, i have find it some how.
Note: There could be N number of rows and columns. And there could be N number of data's like this in a single file. I need a output file with the total number of rows and the how many top columns empty and how many bottom columns empty. 

For any further clarification please post back.


Answers (10)