Using user input to return values from structure

I have a question about structures. I'm trying to have the user input a letter and have the the computer return two values. Here's what I have till now:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
    #include <iostream>
    struct coords{
	int coordsx1;
	int coordsy1;
    } a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;
    int main()
    {
    char first;
    int coordsx1;
    int coordsy1;
		a.coordsx=0;	e.coordsx=0;	i.coordsx=0;	m.coordsx=0;
		b.coordsx=1;	f.coordsx=1;	j.coordsx=1;	n.coordsx=1;
		c.coordsx=2;	g.coordsx=2;	k.coordsx=2;	o.coordsx=2;
		d.coordsx=3;	h.coordsx=3;	l.coordsx=3;	p.coordsx=3;
		cin >> first;
		coordsx1= first.coordsx; // this is the part that doesn't work
    }

For example if the user inputs 'd' for the variable first, I want the computer to set the value of coordsx1 to be equal to 3 and coordsy1 to be equal to 0 (I haven't done the coordsy1 part yet).
Also, is this a good way to return more than one value for a user input?
Also, is this a good way to return more than one value for a user input?
You mean return from a function? Or take from cin? Or something else?

In you case you should probably use switch:

1
2
3
4
5
6
7
8
9
switch(first){
  case 'a' :
    coordsx1 = 0;
    berak;
  case 'b':
    coordsx1 = 1;
    break;
  //...
}
Topic archived. No new replies allowed.