I have to parse different fields of PAT table in this file...
the file looks like this in hex editor...
47 40 00 10 00 00 B0 0D 00 00 C3 00 00 00 01 E0 21 63 0D 38 1E ......
.......
my code is

/*parse1.c*/
    [B]
    #include <stdio.h>
    #include <string.h>
    void main() {

    FILE *f;
    int num[50];
    memset(num,0,50);
    short unsigned int i=0;
    short int rv;
    //short unsigned int num_values;
    f=fopen("screen.ts","r");
    //num[0]='0';
     if (f==0){
        printf("file doesnt exist?!\n");
     }
     while (i<50) {

        rv = fscanf(f, "%d", &num[i]);

        //if (rv != 1)

          //break;        
    i++;
    }
    printf("table id = %d%d \n",num[10],num[11]);
    int section_syntax_indicator=num[12] & 0x0008;
printf("section_syntax_indicator=%d\n",section_syntax_indicator);
    int secl = num[13] & 0x0001;
printf("section length= %d%d%d \n",secl,num[14],num[15]); printf("transportstreamid=%d%d%d%d",num[16],num[17],num[18],num[19]);
    int var1=num[20] & 0x0003;         
    int var2=num[21] & 0x000E;
    int currentnext=num[21] & 0x0001;    
    printf("version no=%d%d \n",var1,var2);
    printf("current_next=%d \n",currentnext);
    printf("section no=%d%d \n",num[22],num[23]);
    printf("last section number=%d%d \n",num[24],num[25]);
   printf("programnumber=%d%d%d%d\n",num[26],num[27],num[28],num[29]);
    int var3=num[30] & 0x0001;    printf("programmapid=%d%d%d%d\n",var3,num[31],num[32],num[33]); 

    if(fclose(f)==0)
     {
    printf("closed");
    }
    }[/B]

the output im getting is:

table id = 00
section_syntax_indicator= 0
section length= 036625504
transport stream id =0012190version no=00
current_next=0
section no=1345133176688432
last section number=1345131321
program number=6623172-10792550886625944-1079255132
program map pid=0-1079255148134513132-1079255160
closed

can anyone suggest me where the problem is?.thanks in advance.

if (f==0){
        printf("file doesnt exist?!\n");
     }

f is a pointer. Your if condition should check whether it is null. And if so print the message and exit.

Also since you are reading a file that contains hexadecimal numbers , it will contain characters from A to F and in fscanf you are reading integers. use %x as format specifier and see if it works

tried both ,but it is not working,giving wrong values...

Just to confirm, you modified the format specifiers in printf as well, right?

Just to confirm, you modified the format specifiers in printf as well, right?

yup