i've got this code it compiles but it when I try to run it it says segmenatation fault

/*
#include <stdio.h>
#include <iostream>

using namespace std;

int rite();
int a,b;
char g,f;

int main ()
{ size_t count;

 FILE * pFile;
 pFile = fopen ("in.h","r");
  count = fscanf (pFile, "%d%d",&a,&b);
  f = fgetc(pFile);
  f = fgetc(pFile);
  fclose (pFile);
  g = 'P';
  if(f == 'P') g = 'V';

  rite();
  return 0;
}

int rite()
{   FILE *wFile; 
  wFile=fopen("out.h","w");
 int k = 0;
 size_t count;

 char ba[] = {'\n'};
 char buffer[b];
 char baffer[b];
 char *buf, *baf;
 buf = buffer;
 baf = baffer;

 for(int h = 0; h <= b;) {*buf = 'F'; ++buf; *buf = 'V'; ++buf; 
		          *baf = 'G'; ++baf; *baf = 'd'; ++baf;}

 	if(a & 0x1) {a = (a -1); k = 1;}

 	for(a = (a/2);a!=0;a--)
 	{count = fwrite(buffer,1,b,wFile);
         count = fwrite(ba,1,1,wFile);

 	 count = fwrite(baffer,1,b,wFile); 
 	 count = fwrite(ba,1,1,wFile);
        
 	}
 
 	if (k) count = fwrite(buffer,1,b,wFile);

return 0;
}

any ideas ? thanx in advance

> for(int h = 0; h <= b;)
How long is the loop going to run before h > b ?

Check ALL your fopen calls for success.

Check your scanf functions for success.

This question has already been answered. Start a new discussion instead.