array of string problem
chin jiunn gai

i use c language.
i have one array of string and one char variable and i want to compare they value is same or not ,so wat should i do .
math_q1 is the question arrays.
The math_a1 store the answers of the question example 2 + 3 =
the multiple choice is 1 : 7, 2 : 6, 3 : 5 the 4 th row store the right answers position.

get the key input 1 or 2 or 3 from user
compare the value key in with the 4 th row of array;
char *math_q1 [5] = {"2 + 3 = ","6 + 7 = ","2 + 8 = ","7 + 10 = ","9 + 12 = "}
char *math_a1 [4][5] = {
{"7","15","8","17","21"},
{"6","14","10","15","22"},
{"5","13","13","13","23"},
{"3","3","2","1","1"}
}
{......}
but problem is answers is char and math_al is array of string
i am doing a quiz game ,is this good way to do this ?

I'd store integers in the table and use atoi to convert the user input to an interger.

Pedro Avelar Gontijo

I really didn't understand what you want to do... but in any case Fladimir's tip should do it
BTW:

The final testing of OpenLayer 2.0 is underway! (Yet another Framebuffer issue solved)

Considering you're changing your sig very instensely, I guess OpenLayer 2.0 is just getting the last hits on the anvil?

chin jiunn gai

my question not only integer but string ,example which is the longest rivers
1 :xx
2 :xx
3 :xx

Then use strcmp instead of the == operator to test the equality of strings. If you want to get really fancy you could also ignore case and strip the trailing and leading spaces from the input etc.

Quote:

Considering you're changing your sig very instensely, I guess OpenLayer 2.0 is just getting the last hits on the anvil?

Maybe I'll just have to solve a color issue with the framebuffers (probably caused by the way that AllegroGL uploads the textures) and a few other things.

chin jiunn gai

so how what code i should write to convert my input to string ? i am use the allegro for the input .and my input either 1,2 or 3 only
or u comment me step how to do quiz game ?

The best way would be to use a real GUI. But if you want to do it by yourself here's a quick article about it.

chin jiunn gai

that article just for text input .
i can get input from user and i am using gui , i just dont write the code inside here .i just show u the problem part .
as u say use strcmp but the input is char type
so how to convert the answers to string
sorry for this ,i really newbiz in programming .

and i want to ask is this the way to do the quiz game .

store the question and answers in array then compare the user input with store answers ... is that something i omit

```char *answer[2];