Question: C++ problem read data from file sort them by name: I try to sort the data by name and here is my code and the

C++ problem read data from file sort them by name:

I try to sort the data by name and here is my code and the data, please help me fix it

void SortByName()

{

char line[MAX_LINE];

string stringVec;

OpenInputFile();

int i = 0;

SkipHeader();

while(fIn.getline(line,MAX_LINE) && i <= MAX_STATES)

{

cout<<"line #"<

line[i] = stringVec[i];

i++;

}

sort(stringVec.begin(),stringVec.end());

for (i=0;i

cout << stringVec << endl;

fIn.close();

}

Idaho Boise 1,297,274

Washington Olympia 5,908,684

Vermont Montpelier 609,890

Hawaii Honolulu 1,216,642

Arizona Phonenix 5,140,683

Montana Helena 905,316

Virginia Richmond 7,100,702

North Dakota Bismarck 643,756

Colorado Denver 4,311,882

Mississippi Jackson 2,852,927

Delaware Dover 785,068

Georgia Atlanta 8,206,975

South Carolina Columbia 4,025,061

Illinois Springfield 12,439,042

Nebraska Lincoln 1,715,369

Arkansas Little Rock 2,679,733

New Hampshire Concord 1,238,415

Ohio Columbus 11,374,540

Kansas Topeka 2,693,824

Louisiana Baton Rouge 4,480,271

Michigan Lansing 9,955,829

Florida Talahasse 16,028,890

Connecticut Hartford 3,409,535

Iowa Des Moines 2,931,923

West Virginia Charleston 1,813,077

Missouri Jefferson 5,606,260

Wyoming Cheyenne 495,304

California Sacramento 33,930,798

Alabama Montgomery 4,461,130

New Jersey Trenton 8,424,354

South Dakota Pierre 756,874

Maryland Annapolis 5,307,886

Indiana Indianapolis 6,090,782

Oklahoma Oklahoma City 3,458,819

North Carolina Raleigh 8,067,673

New York Albany 19,004,973

Rhode Island Providence 1,049,662

Massachusetts Boston 6,355,568

Texas Austin 20,903,994

Kentucky Frankfort 4,049,431

Alaska Juneau 628,933

Utah Salt Lake City 2,236,714

Nevada Carson City 2,002,032

Maine Augusta 1,277,731

Tennessee Nashville 5,700,037

New Mexico Santa Fe 1,823,821

Oregon Salem 3,428,543

Minnesota St. Paul 4,925,670

Wisconsin Madison 5,371,210

Pennsylvania Harrisburg 12,300,670

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!