Go4Expert Member
18Dec2007,13:54   #11
bigbee's Avatar
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
Ambitious contributor
18Dec2007,19:34   #12
Salem's Avatar
Maybe post the code that you ran?
What you posted isn't even close to being able to compile, let alone run.
Go4Expert Member
19Dec2007,03:01   #13
bigbee's Avatar
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!!!
Go4Expert Member
19Dec2007,13:49   #14
bigbee's Avatar
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
Go4Expert Founder
19Dec2007,17:44   #15
shabbir's Avatar
bigbee, Please read http://www.go4expert.com/showthread.php?t=168 for how to post code in the posts
Go4Expert Member
19Dec2007,17:49   #16
bigbee's Avatar
Thanks Shabbir!!! Infact i forgot to do that! Was thinking and pressed submit.....I didnt find way to reedit it..So !!
Go4Expert Founder
19Dec2007,17:51   #17
shabbir's Avatar
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.
Go4Expert Founder
19Dec2007,18:01   #18
shabbir's Avatar
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.
Go4Expert Member
19Dec2007,18:23   #19
bigbee's Avatar
Quote:
Originally Posted by shabbir
Made that to 10 and soon you should see that you are able to edit your posts.
Ok..!