2D Array compile error: "invalid conversion from char to const char*"

so I am trying to finish an assignment before a big exam but I am stuck with this error on line 50: "invalid conversion from char to const char*"

My mind is about blown after typing all this stuff. If anyone can help me straighten this out, that would be a big help.

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
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>

using namespace std;
//Global constants for the dimensions of the arrays
const int MAX_SIZE = 30;
const int MAX_CITIES = 300;
//Function Prototypes
void SortCities(char [MAX_CITIES][MAX_SIZE], char[MAX_CITIES][MAX_SIZE], int [MAX_CITIES], int);
void DisplayCities(char [MAX_CITIES][MAX_SIZE], char[MAX_CITIES][MAX_SIZE], int [MAX_CITIES], int);

int main()
{
ifstream Input;
char City[MAX_CITIES][MAX_SIZE];
char State[MAX_CITIES][MAX_SIZE];
int Population[MAX_CITIES];
int count;
Input.open("cities.txt");
count=0;
//Reads in from cities.txt
while (!Input.eof())
{
      Input.getline(City[count], MAX_SIZE);
      Input.getline(State[count], MAX_SIZE);
      Input >> Population[count] >> ws;
      count++;
      }
      Input.close();

SortCities(City, State, Population, count);
DisplayCities(City, State, Population, count);
}
//Functions
void SortCities(char City[MAX_CITIES][MAX_SIZE], char State[MAX_CITIES][MAX_SIZE], int Population[MAX_CITIES], int count)
{
 char tempstr[MAX_SIZE], lengths[MAX_SIZE];
 int temp, min;
 
 for(int i=0; i<MAX_SIZE; i++)
  {
   min = i;
   for(int x=i+1; x<MAX_SIZE; x++)
     {
     if(strcmp(lengths[x], lengths[min]) < 0)    // THIS IS WHERE I GET ERROR
     {
     min = x;
     strcpy(tempstr[i], lengths[i]);
     strcpy(lengths[i], lengths[min]);
     strcpy(lengths[min], tempstr[i]);
  }
 return;
}

void DisplayCities(char City[MAX_CITIES][MAX_SIZE], char State[MAX_CITIES][MAX_SIZE], int Population[MAX_CITIES], int count)
{
 cout << "Large cities in the United States" << endl << endl;

 for(int i=0; i<MAX_CITIES; i++)
  {
   for(int x=0; x<MAX_SIZE; x++)
      cout << City[i][x] << ", " << State[i][x] << " : " << Population[i] << endl;

   cout << City[i] << ", " << State[i] << " : " << Population[i] << endl;
  }

Last edited on
oh and the cities.txt file is this:

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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
New York City
New York
8274527
Los Angeles
California
3834340
Chicago
Illinois
2836658
Houston
Texas
2208180
Phoenix
Arizona
1552259
Philadelphia
Pennsylvania
1449634
San Antonio
Texas
1328984
San Diego
California
1266731
Dallas
Texas
1240499
San Jose
California
939899
Detroit
Michigan
916952
Jacksonville
Florida
805605
Indianapolis
Indiana
795458
San Francisco
California
764976
Columbus
Ohio
747755
Austin
Texas
743074
Fort Worth
Texas
681818
Memphis
Tennessee
674028
Charlotte
North Carolina
671588
Baltimore
Maryland
637455
El Paso
Texas
606913
Milwaukee
Wisconsin
602191
Boston
Massachusetts
599351
Seattle
Washington
594210
Nashville
Tennessee
590807
Denver
Colorado
588349
Washington
District of Columbia
588292
Las Vegas
Nevada
558880
Louisville
Kentucky
557789
Portland
Oregon
550396
Oklahoma City
Oklahoma
547274
Tucson
Arizona
525529
Atlanta
Georgia
519145
Albuquerque
New Mexico
518271
Fresno
California
470508
Long Beach
California
466520
Sacramento
California
460242
Mesa
Arizona
452933
Kansas City
Missouri
450375
Cleveland
Ohio
438042
Virginia Beach
Virginia
434743
Omaha
Nebraska
424482
Miami
Florida
409719
Oakland
California
401489
Tulsa
Oklahoma
384037
Minneapolis
Minnesota
377392
Colorado Springs
Colorado
376427
Raleigh
North Carolina
375806
Honolulu
Hawaii
375571
Arlington
Texas
371038
Wichita
Kansas
361420
St. Louis
Missouri
350759
Santa Ana
California
339555
Tampa
Florida
336823
Anaheim
California
333249
Cincinnati
Ohio
332458
Bakersfield
California
315837
Aurora
Colorado
311794
Pittsburgh
Pennsylvania
311218
Toledo
Ohio
295029
Riverside
California
294437
Stockton
California
287245
Corpus Christi
Texas
285507
Newark
New Jersey
280135
Anchorage
Alaska
279671
Lexington
Kentucky
279044
St. Paul
Minnesota
277251
Buffalo
New York
272632
Plano
Texas
260796
Glendale
Arizona
253152
Fort Wayne
Indiana
251247
Henderson
Nevada
249386
Lincoln
Nebraska
248744
Greensboro
North Carolina
247183
St. Petersburg
Florida
246407
Chandler
Arizona
246399
Jersey City
New Jersey
242389
New Orleans
Louisiana
239124
Norfolk
Virginia
235747
Scottsdale
Arizona
235677
Birmingham
Alabama
229800
Madison
Wisconsin
228775
Orlando
Florida
227907
Baton Rouge
Louisiana
227071
Chesapeake
Virginia
219154
Garland
Texas
218792
Durham
North Carolina
217847
Laredo
Texas
217506
Chula Vista
California
217478
Lubbock
Texas
217326
Winston-Salem
North Carolina
215348
Reno
Nevada
214853
Hialeah
Florida
212217
North Las Vegas
Nevada
212114
Akron
Ohio
207934
Gilbert
Arizona
207550
Rochester
New York
206759
Arlington
Virginia
204568
Montgomery
Alabama
204086
Modesto
California
203955
Boise
Idaho
202832
Fremont
California
201334
Irvine
California
201160
Spokane
Washington
200975
Richmond
Virginia
200123
Shreveport
Louisiana
199569
Irving
Texas
199505
San Bernardino
California
199285
Yonkers
New York
199244
Des Moines
Iowa
196998
Glendale
California
196979
Tacoma
Washington
196520
Grand Rapids
Michigan
193627
Huntington Beach
California
192885
Augusta
Georgia
192142
Mobile
Alabama
191411
Moreno Valley
California
188936
Little Rock
Arkansas
187452
Columbus
Georgia
187046
Amarillo
Texas
186106
Oxnard
California
184725
Fort Lauderdale
Florida
183606
Knoxville
Tennessee
183546
Fontana
California
183502
Salt Lake City
Utah
180651
Newport News
Virginia
179153
Jackson
Mississippi
175710
Tempe
Arizona
174091
Worcester
Massachusetts
173966
Brownsville
Texas
172806
Providence
Rhode Island
172459
Fayetteville
North Carolina
171853
Huntsville
Alabama
171327
Ontario
California
170936
Aurora
Illinois
170855
Rancho Cucamonga
California
170266
Santa Clarita
California
169951
Chattanooga
Tennessee
169884
Overland Park
Kansas
169403
Tallahassee
Florida
168979
Oceanside
California
168602
Garden Grove
California
165610
Vancouver
Washington
161436
Grand Prairie
Texas
158422
Cape Coral
Florida
156981
Rockford
Illinois
156596
Dayton
Ohio
155461
Springfield
Missouri
154777
Santa Rosa
California
154241
Pomona
California
152631
Salem
Oregon
151913
Sioux Falls
South Dakota
151505
Port St. Lucie
Florida
151391
Corona
California
150308
Springfield
Massachusetts
149938
Eugene
Oregon
149004
Pembroke Pines
Florida
146828
Peoria
Arizona
146743
Paterson
New Jersey
146545
Pasadena
Texas
146518
Hampton
Virginia
146439
Joliet
Illinois
144316
Lancaster
California
143616
Salinas
California
143517
Pasadena
California
143400
Naperville
Illinois
142479
Hollywood
Florida
142473
Kansas City
Kansas
142320
Torrance
California
141420
Hayward
California
140943
Palmdale
California
140882
Lakewood
Colorado
140305
Alexandria
Virginia
140024
Syracuse
New York
139079
Bridgeport
Connecticut
136695
Escondido
California
136246
Orange
California
134299
Warren
Michigan
134223
Fort Collins
Colorado
133899
Fullerton
California
132066
Mesquite
Texas
131738
Elk Grove
California
131212
Sunnyvale
California
131140
Savannah
Georgia
130331
Sterling Heights
Michigan
127349
McAllen
Texas
127245
Coral Springs
Florida
126875
Cedar Rapids
Iowa
126396
Elizabeth
New Jersey
124862
Columbia
South Carolina
124818
Hartford
Connecticut
124563
New Haven
Connecticut
123932
Carrollton
Texas
123799
Thousand Oaks
California
123349
Topeka
Kansas
122642
West Valley City
Utah
122374
El Monte
California
122272
Waco
Texas
122222
Cary
North Carolina
121796
Bellevue
Washington
121347
Concord
California
120844
Simi Valley
California
120464
Clarksville
Tennessee
119284
Visalia
California
118603
Stamford
Connecticut
118475
Olathe
Kansas
118034
Provo
Utah
117592
Springfield
Illinois
117090
Evansville
Indiana
116253
Abilene
Texas
116219
McKinney
Texas
115620
Vallejo
California
115552
Denton
Texas
115506
Ann Arbor
Michigan
115092
Lansing
Michigan
114947
Flint
Michigan
114662
Gainesville
Florida
114375
Peoria
Illinois
113546
Lafayette
Louisiana
113544
Inglewood
California
113376
Athens
Georgia
112760
Killeen
Texas
112434
Thornton
Colorado
110880
Independence
Missouri
110704
Charleston
South Carolina
110015
Santa Clara
California
109756
Beaumont
Texas
109579
Costa Mesa
California
108978
Manchester
New Hampshire
108874
Roseville
California
108759
Miramar
Florida
108240
Downey
California
108109
Victorville
California
107221
Waterbury
Connecticut
107174
Allentown
Pennsylvania
107117
Norman
Oklahoma
106707
Clearwater
Florida
106642
West Covina
California
106388
Arvada
Colorado
106328
Westminster
Colorado
106195
Elgin
Illinois
104288
South Bend
Indiana
104069
Fairfield
California
103992
Midland
Texas
103880
Pueblo
Colorado
103805
Norwalk
California
103720
Erie
Pennsylvania
103650
Lowell
Massachusetts
103512
Burbank
California
103286
San Buenaventura
California
103219
Pompano Beach
Florida
102745
West Jordan
Utah
102445
Portsmouth
Virginia
101967
Billings
Montana
101876
Wichita Falls
Texas
101590
Richmond
California
101454
Cambridge
Massachusetts
101388
Berkeley
California
101377
Daly City
California
100882
Green Bay
Wisconsin
100781
High Point
North Carolina
100432
Palm Bay
Florida
100116
Last edited on
The error is because "lengths" is an array of characters, *not* an array of char*s.
To be a bit more specific: lengths[#] is of type char, and strcmp() wants two variables, each of type char*.
Topic archived. No new replies allowed.