problem using char types with VASK library

T.W.CHARNOCK CHARNOTW at charlie.aston.ac.uk
Mon Feb 28 10:58:01 EST 1994


I am having a problem with the vask library  when I use structures
and arrays of structures containing characters.  The following short
program illustrates this:

#include<gis.h>

struct char_record
  {
  char a;
  char b;
  };

struct char_record char_array[2];

main(argc,argv) 
int argc;
char* argv[];
  {
  G_gisinit(argv[0]);

  char_array[0].a='a';
  char_array[0].b='b';
  char_array[1].a='c';
  char_array[1].b='d';
  
  V_clear();

  V_ques(&char_array[0].a,'s',3,4,1);
  V_ques(&char_array[0].b,'s',3,10,1);
  V_ques(&char_array[1].a,'s',4,4,1);
  V_ques(&char_array[1].b,'s',4,10,1);

  V_call();
  }

this should produce a screen looking something like this:

    a      b
    c      d

when I use <enter> to move through the fields I get this:

   abcd bcd
   cd     d

for some reason it is printing the succeeding characters in the
structure, in unspecified places, arrgh.  I get the same problem if I
use the definition:

char a[1];

I can remove the problem if I seperate the variables by some dummy
variable eg:

char a;
int dummy;
char b;

this seems weird to me, any ideas what I'm doing wrong?  I'm
using gcc compiler on a SUN SPARC  under openwindows and
SUNOS 4.something.

cheers  Tom

Tom Charnock               
Dept Civil Engineering     
Aston University          
Birmingham B7 5NJ UK                           
charnotw at aston.ac.uk     



More information about the grass-dev mailing list