segmentation fault

hello i am using g++ and trying to make a terminal application that siphons out the notes in the major scale(ionian mode) of a given key. it has compiled but as soon as i enter my user input it gives me a segmentation fault. i cannot for the life of me figure out whats going on. any help would be much appreciated; thank you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <string>
#include <iostream>
#include <sstream>

using namespace std;

string chromatic_scale[12] = {"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"};
string* ionian_mode[7];
string UI = "";

void get_UI()
{
	cout<<"choose a key"<<endl;
	for(int i = 0; i < 12; i++)
		cout<<chromatic_scale[i]<<", ";
	cout<<endl;
	getline(cin, UI);
}

void output_scale()
{
	for(int i = 0; i < 7; i++)
		cout<< *ionian_mode[i]<< ", ";
	cout<<endl;
}

void whole_step(int* i)
{
	*i =+ 2;
	if(*i >= 12) *i =- 12;
}

void half_step(int* i)
{
	*i =+ 1;
	if(*i >= 12) *i =- 12;
}

void assign_ionian_mode()
{

	int i = 0;

	while(UI != chromatic_scale[i])
	{
		i++;
	};

	ionian_mode[0] = &chromatic_scale[i];
	whole_step(&i);
	ionian_mode[1] = &chromatic_scale[i];
	whole_step(&i);
	ionian_mode[2] = &chromatic_scale[i];
	half_step(&i);
	ionian_mode[3] = &chromatic_scale[i];
	whole_step(&i);
	ionian_mode[4] = &chromatic_scale[i];
	whole_step(&i);
	ionian_mode[5] = &chromatic_scale[i];
	whole_step(&i);
	ionian_mode[6] = &chromatic_scale[i];
}

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

get_UI();
assign_ionian_mode();
output_scale();

return 0;
}


thanks again.
I think in your whole_step() and half_step() functions you meant to use += and -=, not the other way around. a += 1 is the same as a = a + 1 but a =+ 1 is the same as saying a = +1 or a = 1, which is not what you want.
:-O omg thank you so much Zhuge!!!!! that did it. for some reason i thought i had read somewhere that += and =+ where synonymous. thanks again.
Topic archived. No new replies allowed.