[A89] c trouble
[Next][Index][Thread]
[A89] c trouble
I'm having trouble with arrays of strings. What I'm trying to do is make
a function that will cycle through a list of options. The options are in
an array of strings.
void main(void)
{
char options[3][6] = {"yes ", "no ", "maybe"};
...
scroll_field(3, options, (INT_POINT){18*8,0}, GrWhite(), GrBlack());
...
}
The relevant parts of the scroll_field definition are:
int scroll_field(int number_of_options,
char option_str[number_of_options][],
INT_POINT location, GrColor fgc, GrColor bgc)
{
int option = 1;
...
GrTextXY(location.x, location.y, option_str[option - 1], fgc, bgc);
...
}
The function GrTextXY() takes a string as the 3rd argument.
As you've probably guessed, this isn't for a 89 program. I'm using
DJGPP. It gives the error "arithmetic on pointer to incomplete type"
twice on the line with GrTextXY().
I found the source of a program with a similar function. They used a
buffer and strcpy, so I tried that:
int scroll_field(int number_of_options,
char option_str[number_of_options][],
INT_POINT location, GrColor fgc, GrColor bgc)
{
int option = 1;
char buffer[81];
...
strcpy(buffer, option[option - 1]);
GrTextXY(location.x, location.y, buffer, fgc, bgc);
...
}
As expected, the GrTextXY() line was fine and the strcpy() line produced
an error: "subscripted value is neither array nor pointer". Someone
please help me.
________________________________________________________________
The best thing to hit the internet in years - Juno SpeedBand!
Surf the web up to FIVE TIMES FASTER!
Only $14.95/ month - visit www.juno.com to sign up today!
Follow-Ups: