R6010 Error

This is my data.
john smith#165980076#8148337965#3rd & state st#erie#pa#16506

R6010
-abort() has been called

This was today's lab... I spend Four hour and its giving me error.....
This is my coding below
No idea where i made my mistake...


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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include <iostream>
#include <string> 
#include <fstream> 
using namespace std;
string fixName(string n);
string fixSSN(string ss);
string fixPhone(string ph);
string fixAddress(string addr);
string fixCity(string cty);
string fixState(string st);
string ExtractField(string& s);
void buildLine(string&s, string field);
const string SPACE = " ", SHOP = "#", COMMA = ",", DASH = "-";
int main()
{
	string Data, lineOut;
	string Name, SSN, Phone, Address, City, State;
	ifstream namefile;
	namefile.open("badnames.txt");

	while (namefile >> Data)
	{
		lineOut = " ";
		//get first and last name 
		Name = ExtractField(Data);
		Name = fixName(Name);
		buildLine(lineOut, Name);
		// get ssd number 
		SSN = ExtractField(Data);
		SSN = fixSSN(SSN);
		buildLine(lineOut, SSN);
		//Phone
		Phone = ExtractField(Data);
		Phone = fixPhone(Phone);
		buildLine(lineOut, Phone);
		//get address in return capital first letter
		Address = ExtractField(Data);
		Address = fixAddress(Address);
		buildLine(lineOut, Address);
		// capital city and return
		City = ExtractField(Data);
		City = fixCity(City);
		buildLine(lineOut, City);
		// capital PA
		State = ExtractField(Data);
		State = fixState(State);
		buildLine(lineOut, State);
		
	}
	namefile.close();
	return 0;
}
string ExtractField(string& s)
{
	int loc;
	string str;
	loc = s.find(SHOP);
	s.erase(0, loc + 1);
	return str;

}
string fixName(string n)
{
	int loc;
	string name, first;
	loc = n.find(SPACE);
	n[0] = toupper(n[0]);
	n[loc + 1] = toupper(n[loc + 1]);
	first = n.substr(0, loc);
	name = n.substr(loc + 1) + COMMA + first;
	return name;
}

string fixSSN(string ss)
{//yes i don't need SSN1,2,3 etc but i like to keep it this way.
	string SSN;
	SSN = ss;
	SSN.insert(5, DASH);
	SSN.insert(3, DASH);
	return SSN;
}
string fixPhone(string ph)
{
	string phone;
	phone = ph;
	//yes i don't need PHONE1,2,3 etc but i like to keep it this way.
	phone.insert(6, DASH);
	phone.insert(3, DASH);
	return phone;
}
string fixAddress(string addr)
{
	string fixedvrs;
	//TA helped me on this part 
	// basically loop to capital every first letter
	int loc = 0, loc1 = 0;
	do{// -1 does not exist so when I hit last charcter it will help me get out from loop. 
		if (loc != -1)
		{
			addr[loc + 1] = toupper(addr[loc + 1]);
			loc1 = loc + 1;
		}
	} while (loc != -1);
	fixedvrs;
	return fixedvrs;
}
string fixCity(string cty)
{
	cty[0] = toupper(cty[0]);
	return cty;
}
string fixState(string st)
{	//first letter capitalized
	st[0] = toupper(st[0]);
	//2nd letter capitalized
	st[1] = toupper(st[1]);
	return st;
}
void buildLine(string&s, string field)
{
	s += field;
	//add comma after add filed = name,ssn,phone, etc
	s += COMMA;
}


And I get Abort R6010
Last edited on
Hey. Please edit your post and put all of your code between code tags. Its under the format: section and the icon looks like this <>. Mark all of your code and then click the icon.

http://www.cplusplus.com/articles/jEywvCM9/
Topic archived. No new replies allowed.