category labels

Hi,

I have a question concerning category labels updating.
I try to write a routine to fill up all the empty category labels.
The problem is that I can not write those changes into
category file (G_write_cats). I have tested it, and until that
command Categories structure is correct.
Is it HP specific problem?
A work on Apollo HP under HP-UX.
Have anyone had similar problems? Please let me know how to solve it.

Thanks in advance,

Robert Szczepanek
Cracow University of Technology
E-mail: robert@profek.wis.pk.edu.pl

/*************************************************/
fill_labels(char *map)
{
int x, i;
char string[100];
struct Categories *cats;

G_read_cats(map,G_mapset(),&cats);

printf("category: ");
scanf("%d",&x);
printf("%s\n",G_get_cat(x,&cats));

printf("new label: ");
getchar();
gets(string);

G_set_cat(x,string,&cats);
G_write_cats("test",&cats); <- segmentation fault

return;
}
/**************************************************/