0
bigbee's Avatar, Join Date: Dec 2007
Go4Expert Member
HI,

Its giving a Segmentation Fault Can u see to it once?

Code:
Type = INT 
ROW = 320
COL = 250 
FORMAT = %x
TYPE  *buf1[ROW][COL]
 if((stream = fopen(argv[1],"rb" ))!= NULL )
    {
      numread = fread(buf1,sizeof(int),size,stream );
      fclose( stream );       
      printf( "Number of items read = %d\n", numread );
     
    if[(pos < 240000)
        {
	  for(row=0;row<320;row++){
	    for(col=0;col<250;col++){
	      if (buf1[row][col] != 0)
		printf(FORMAT,buf1[pos]);
               pos++;
	    }
	  }
    }
But how can i use the pos with reepect to total size?
And i have declared buf1[row][col]

Last edited by shabbir; 18Dec2007 at 17:56.. Reason: Code block
0
Salem's Avatar, Join Date: Nov 2007
Ambitious contributor
Maybe post the code that you ran?
What you posted isn't even close to being able to compile, let alone run.
0
bigbee's Avatar, Join Date: Dec 2007
Go4Expert Member
Ok i will post it tommorow morning ..do look at it once ....Actually i will post the complete which has someother stuff related to what i am doing!
SO u can trim it out or i will try to trim only the part which i need!!!
0
bigbee's Avatar, Join Date: Dec 2007
Go4Expert Member
Code:
#include <tk.h>
#include <tcl.h>
#include "commands.h"
#define TYPE       int
#define FORMAT     "%8x"
#define size 240000
#define ROW 320
#define COL 250

static void
usage (void)
{
  fprintf(stderr, "\
  usage: Pacman FILE_NAME\n");
}

int
Tcl_Pacman(ClientData clientData,
	   Tcl_Interp * interp,
	   int argc , char *argv[])
{
  FILE  *stream;
  int   numread;
 TYPE  *buf1[ROW][COL];
  int i,j,k;
  int row, col, pos = 0;
  
  if (argc!= 2)
    {
      usage();
    } 
  
  if((stream = fopen(argv[1],"rb" ))!= NULL )
    {
      numread = fread(buf1,sizeof(int),size,stream );
      fclose( stream );       
      printf( "Number of items read = %d\n", numread );
      
      if(pos <  240000)  
      {
      for(row=0;row<320;row++){
	  for(col=0;col<250;col++){
	      if (buf1[row][col] != 0)
	        printf(FORMAT,buf1[ROW][COL]);
	    }
	  }
    }
   else
    {
      printf( "File %s could not be opened\n",argv[1]);
      return 0;
    }
      
}
Well if you find any bracket missing or more...DO ignore it!
And this is only the main part .
Should i attach the bin file also which i have to read

Regards,

Last edited by shabbir; 19Dec2007 at 17:43.. Reason: Code block
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
bigbee, Please read http://www.go4expert.com/showthread.php?t=168 for how to post code in the posts
0
bigbee's Avatar, Join Date: Dec 2007
Go4Expert Member
Thanks Shabbir!!! Infact i forgot to do that! Was thinking and pressed submit.....I didnt find way to reedit it..So !!
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by bigbee
Thanks Shabbir!!! Infact i forgot to do that! Was thinking and pressed submit.....I didnt find way to reedit it..So !!
You can re-edit the posts after you have 25 posts but as that is the problem many of us are facing and We are planning to get that number in single figure.
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by shabbir
You can re-edit the posts after you have 25 posts but as that is the problem many of us are facing and We are planning to get that number in single figure.
Made that to 10 and soon you should see that you are able to edit your posts.
0
bigbee's Avatar, Join Date: Dec 2007
Go4Expert Member
Quote:
Originally Posted by shabbir
Made that to 10 and soon you should see that you are able to edit your posts.
Ok..!