I'm sorry, I didn't realize I couldn't upload the exe file - but I have it ready to email.

I'm having a big problem understanding how to complete this assignment and would really appreciate someone's help in getting me started.

Basically, we are taking baby names from a file and opening the file up in our program. we are using arrays (I believe a 2 dimensional array) and taking it from a file named babynames2004.txt and putting that data into the array.

this program is supposed to output to the screen:
"Enter the first name that you would like to find the
popularity of from baby names in 2004.
Be sure to capitalize the first letter of the name."

if you enter Melissa, for example, it will output:

"Melissa is not ranked among the top 1000 boy names.
Melissa is ranked 100 in popularity among girls
Press any key to continue..."

I have attached the text file fo anyone willing to help me continue the project.

I have to load the boy names and the girl names from the file into separate arrays and search for the target name from the arrays, not directly from the file.

here is what I have so far, someone pleeeease help me :)

#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;





int main
{
    ifstream in_put;
    char enter_name
    
    in_put.open("babynames2004.txt");
    if (in_put.fail())
    {
       cout << "Input file opening failed.\n";
       exit(1)
    }
    
    cout << "Enter the first name that you would like to find the\n;"
         << "popularity of from baby names in 2004.\n;"
         << "Be sure to capitalize the first letter of the name.\n"
    cin >> enter_name;
    
    int index = 0, count = 0;
    char boys_name[1000][10], girls_name[1000][10];
    char data;
    
    while (in_put.get(data))
    {     
          boys_name[index][count] = data;
          girls_name[index][count] = data;
          
          for (count += 1; count < 10; count ++)
          {
              char boys_name[index][count] = input.get(data);
              if (data == ' ')
                 char girls_name [index][count] = in_put.get(data);
                 
    }
    
    
    
    
    
    
    system("Pause");
    
    return 0;
    
}
Attachments
1 Jacob Emily
2 Michael Emma
3 Joshua Madison
4 Matthew Olivia
5 Ethan Hannah
6 Andrew Abigail
7 Daniel Isabella
8 William Ashley
9 Joseph Samantha
10 Christopher Elizabeth
11 Anthony Alexis
12 Ryan Sarah
13 Nicholas Grace
14 David Alyssa
15 Alexander Sophia
16 Tyler Lauren
17 James Brianna
18 John Kayla
19 Dylan Natalie
20 Nathan Anna
21 Jonathan Jessica
22 Brandon Taylor
23 Samuel Chloe
24 Christian Hailey
25 Benjamin Ava
26 Zachary Jasmine
27 Logan Sydney
28 Jose Victoria
29 Noah Ella
30 Justin Mia
31 Elijah Morgan
32 Gabriel Julia
33 Caleb Kaitlyn
34 Kevin Rachel
35 Austin Katherine
36 Robert Megan
37 Thomas Alexandra
38 Connor Jennifer
39 Evan Destiny
40 Aidan Allison
41 Jack Savannah
42 Luke Haley
43 Jordan Mackenzie
44 Angel Brooke
45 Isaiah Maria
46 Isaac Nicole
47 Jason Makayla
48 Jackson Trinity
49 Hunter Kylie
50 Cameron Kaylee
51 Gavin Paige
52 Mason Lily
53 Aaron Faith
54 Juan Zoe
55 Kyle Stephanie
56 Charles Jenna
57 Luis Andrea
58 Adam Riley
59 Brian Katelyn
60 Aiden Angelina
61 Eric Kimberly
62 Jayden Madeline
63 Alex Mary
64 Bryan Leah
65 Sean Lillian
66 Owen Michelle
67 Lucas Amanda
68 Nathaniel Sara
69 Ian Sofia
70 Jesus Jordan
71 Carlos Alexa
72 Adrian Rebecca
73 Diego Gabrielle
74 Julian Caroline
75 Cole Vanessa
76 Ashton Gabriella
77 Steven Avery
78 Jeremiah Marissa
79 Timothy Ariana
80 Chase Audrey
81 Devin Jada
82 Seth Autumn
83 Jaden Evelyn
84 Colin Jocelyn
85 Cody Maya
86 Landon Arianna
87 Carter Isabel
88 Hayden Amber
89 Xavier Melanie
90 Wyatt Diana
91 Dominic Danielle
92 Richard Sierra
93 Antonio Leslie
94 Jesse Aaliyah
95 Blake Erin
96 Sebastian Amelia
97 Miguel Molly
98 Jake Claire
99 Alejandro Bailey
100 Patrick Melissa
101 Carson Brooklyn
102 Victor Katie
103 Alexis Nevaeh
104 Caden Catherine
105 Kaden Angela
106 Riley Amy
107 Brayden Isabelle
108 Bryce Jacqueline
109 Trevor Jade
110 Henry Gabriela
111 Jeremy Madelyn
112 Liam Shelby
113 Mark Mariah
114 Garrett Gracie
115 Marcus Kennedy
116 Tristan Mya
117 Ivan Breanna
118 Kaleb Daniela
119 Vincent Adriana
120 Jorge Briana
121 Kenneth Courtney
122 Brady Kathryn
123 Oscar Christina
124 Tanner Gianna
125 Joel Alexandria
126 Eduardo Lydia
127 Jared Miranda
128 Paul Angel
129 Edward Laura
130 Collin Alicia
131 Alan Ashlyn
132 Parker Alexia
133 Cooper Margaret
134 Conner Peyton
135 Colton Rylee
136 Maxwell Sophie
137 Dakota Kendall
138 Nicolas Kelly
139 Cristian Summer
140 Stephen Ana
141 Grant Kylee
142 Peter Reagan
143 Ricardo Natalia
144 Josiah Daisy
145 Gage Lindsey
146 Brendan Naomi
147 Omar Kate
148 George Kelsey
149 Jeffrey Sabrina
150 Francisco Alondra
151 Spencer Jillian
152 Preston Cheyenne
153 Braden Mckenzie
154 Fernando Karen
155 Derek Skylar
156 Levi Paris
157 Cesar Mikayla
158 Javier Ruby
159 Damian Payton
160 Eli Addison
161 Peyton Caitlin
162 Nolan Kyla
163 Micah Juliana
164 Max Caitlyn
165 Travis Abby
166 Dalton Crystal
167 Shane Layla
168 Manuel Cassidy
169 Andres Delaney
170 Edgar Bianca
171 Shawn Mariana
172 Erik Charlotte
173 Edwin Cassandra
174 Emmanuel Tiffany
175 Devon Valeria
176 Bradley Angelica
177 Jonah Carly
178 Mario Alana
179 Erick Valerie
180 Malachi Jasmin
181 Ty Hope
182 Ayden Giselle
183 Johnathan Erica
184 Wesley Jazmin
185 Colby Genesis
186 Trenton Jordyn
187 Donovan Mallory
188 Raymond Kiara
189 Giovanni Ellie
190 Jalen Aubrey
191 Hector Serenity
192 Marco Erika
193 Abraham Veronica
194 Gregory Chelsea
195 Leonardo Karla
196 Dillon Karina
197 Damien Sadie
198 Clayton Eva
199 Bryson Jamie
200 Andre Julianna
201 Sergio Brenda
202 Roberto Mckenna
203 Martin Celeste
204 Jaylen Lucy
205 Andy Alejandra
206 Dawson Maggie
207 Elias Zoey
208 Josue Amaya
209 Brody Esmeralda
210 Harrison Adrianna
211 Drew Bethany
212 Corey Makenzie
213 Mitchell Lilly
214 Scott Elena
215 Israel Nadia
216 Taylor Jayla
217 Ruben Meghan
218 Dominick Cadence
219 Braxton Kyra
220 Calvin Ariel
221 Miles Aliyah
222 Brett Cynthia
223 Dustin Camryn
224 Rafael Liliana
225 Pedro Elise
226 Avery Monica
227 Troy Makenna
228 Jace Kailey
229 Oliver Alison
230 Frank Lizbeth
231 Zane Hanna
232 Camden Vivian
233 Ronald Macy
234 Jakob Jayden
235 Gerardo Desiree
236 Skyler Haylee
237 Payton Rebekah
238 Trey Allyson
239 Roman Carmen
240 Armando Brittany
241 Griffin Lindsay
242 Raul Josephine
243 Malik Nina
244 Marcos Hayley
245 Brock Heather
246 Alec Jazmine
247 Derrick Asia
248 Kai Laila
249 Phillip Jaden
250 Keith Camille
251 Cade Kara
252 Chance Cameron
253 Johnny Katelynn
254 Enrique Carolina
255 Keegan Joanna
256 Simon Shannon
257 Allen Selena
258 Trent Keira
259 Xander Aniya
260 Casey Bella
261 Jaiden Julie
262 Drake Reese
263 Cayden Raven
264 Donald Kristen
265 Leo Piper
266 Jaxon Guadalupe
267 Fabian Heaven
268 Corbin Diamond
269 Julio Kendra
270 Angelo Savanna
271 Dante Claudia
272 Jaime Fatima
273 Grayson Alaina
274 Kyler Kira
275 Lance Dakota
276 Kameron Cecilia
277 Brenden Tessa
278 Zander April
279 Emanuel Miriam
280 Jimmy Sandra
281 Landen Katrina
282 Alberto Kayleigh
283 Tyson Ashlee
284 Chandler Michaela
285 Darius Clara
286 Tucker Anastasia
287 Adan Camila
288 Zackary Ashlynn
289 Gustavo Nancy
290 Saul Tatiana
291 Santiago Stella
292 Mathew Jadyn
293 Jerry Holly
294 Lukas Aniyah
295 Myles Kaitlin
296 Lane Allie
297 Lorenzo Kirsten
298 Nickolas Kamryn
299 Brennan Annabelle
300 Emilio Natasha
301 Nikolas Serena
302 Louis Alayna
303 Pablo Cindy
304 Danny Esther
305 Aden Eleanor
306 Quinn Nora
307 Philip Wendy
308 Arturo Bridget
309 Kaiden Kaylie
310 Dennis Skyler
311 Zion Julissa
312 Morgan Emilee
313 Theodore Eliana
314 Damon Emely
315 Randy Melody
316 Bryant Rylie
317 Ezekiel Patricia
318 Kayden Kathleen
319 Jayson Lexi
320 Tony Eliza
321 Mateo Aurora
322 Curtis Daniella
323 Yahir Tara
324 Braeden Kristina
325 Axel Annika
326 Alfredo Josie
327 Gary Fiona
328 Hudson Jayda
329 Quentin Brenna
330 Tristen Ciara
331 Jonathon Meredith
332 Ismael Madeleine
333 Larry Alivia
334 Darren Yasmin
335 Marc Marisa
336 Brayan Yesenia
337 Asher Alissa
338 Albert Mercedes
339 Camron Talia
340 Amir Paola
341 Ryder Eden
342 Salvador Kassandra
343 Maximilian Leilani
344 Ramon Heidi
345 Chad Callie
346 Mekhi Brooklynn
347 Ernesto Cierra
348 Joe Priscilla
349 Charlie Shayla
350 Cory Britney
351 Esteban Logan
352 Jay Ruth
353 Douglas Leila
354 Marvin Marina
355 Dallas Nia
356 Keaton Denise
357 Arthur Brynn
358 Abel Harley
359 Orlando Perla
360 Ricky Rose
361 Moises Sage
362 Eddie Itzel
363 Lawrence Kiana
364 Russell Helen
365 Emiliano Samara
366 Walter Clarissa
367 Hugo Georgia
368 Mauricio Janiya
369 Carl Kiley
370 Holden Sasha
371 Gael Tori
372 Rylan Christine
373 Kristopher Kaydence
374 Dean Sidney
375 Jude Tamia
376 Davis Rachael
377 Marshall Iris
378 Maddox Kiera
379 Ali Angie
380 Weston Kyleigh
381 Walker Anahi
382 Ezra Tatum
383 Julius Casey
384 Isiah Shania
385 Joaquin Ivy
386 Maurice Annie
387 Tate Halle
388 Kade Kadence
389 Rodrigo Lauryn
390 Reese Alina
391 Reece Imani
392 Micheal Nayeli
393 Felix Hailee
394 Luca Bryanna
395 Tommy Izabella
396 Chris Marisol
397 Issac Ainsley
398 Elliot Anne
399 Shaun Skye
400 Terry Ximena
401 Caiden Madalyn
402 Beau Kassidy
403 Brent Genevieve
404 Bennett Nyla
405 Javon Alice
406 Justice Madisyn
407 Amari Phoebe
408 Guillermo Ryleigh
409 Osvaldo Lesly
410 Kody Joselyn
411 Kelvin Teresa
412 Jaylin Liberty
413 Jon Lucia
414 Deandre Maritza
415 Kobe Ashleigh
416 Roger Paulina
417 Braydon Regan
418 Easton Rosa
419 Branden Taryn
420 Zachery Carolyn
421 Jeffery Gloria
422 Graham Linda
423 Jaylon Lacey
424 Khalil Amya
425 Jamari Alexus
426 Toby Dayanara
427 Silas Dana
428 Maximus Francesca
429 Zachariah Jaiden
430 Jadon Kaylin
431 Melvin Lisa
432 Bailey Tiana
433 Declan Viviana
434 Rodney Amari
435 Demetrius Krystal
436 Sawyer Ryan
437 Noe Cristina
438 Dorian Virginia
439 Felipe Cora
440 Sam Hallie
441 Reid Isabela
442 Uriel Jenny
443 Davion Raquel
444 Nathanael Elisabeth
445 Allan Larissa
446 Jamal Tabitha
447 Marquis Malia
448 Omarion Noelle
449 Frederick Whitney
450 Conor Alisha
451 Noel Kaitlynn
452 Trevon Janet
453 Bobby Deanna
454 Rene Madyson
455 Jessie Kiersten
456 Brendon Elaina
457 Elliott Emilie
458 Nelson Alyson
459 Jermaine Dulce
460 Jonas Jane
461 Billy Monique
462 Harley Nataly
463 Jaxson Tania
464 Wilson Jimena
465 Gerald Lana
466 Damion Kaleigh
467 Desmond Anya
468 Dane Ayanna
469 Quincy Carla
470 Roy Emilia
471 Skylar Sarai
472 Terrance Macie
473 Leonel Alanna
474 Rogelio Dylan
475 Quinton Carissa
476 Rowan Renee
477 Craig Anika
478 Rohan India
479 Bruce Simone
480 Kenny America
481 Solomon Valentina
482 Tomas Marlene
483 Kristian Joy
484 Nasir Athena
485 Reed Jessie
486 Ahmad Miracle
487 Amarion Haleigh
488 Kanye Brielle
489 Franklin Raegan
490 Reginald Brittney
491 Terrell Elisa
492 Kolby Lila
493 Joey Elle
494 Jaydon Baylee
495 Willie Fernanda
496 Jaquan Marie
497 Kadin Justice
498 Triston Ellen
499 Rodolfo Laci
500 Devan Madilyn
501 Steve Johanna
502 Isaias Carlie
503 Zackery Dominique
504 Dayton Jaelyn
505 Johnathon Alessandra
506 Mohamed Yasmine
507 Tobias Carley
508 Kendall Cara
509 Byron Aileen
510 Kellen Anaya
511 Cyrus Martha
512 Alvin Kendal
513 Deven Tia
514 Moses Kristin
515 Pierce Maddison
516 Jameson Marley
517 Kendrick Jaqueline
518 Jarrett Abbigail
519 Jayce Destinee
520 Leon Teagan
521 Marlon Kaley
522 Wade Lena
523 Alfonso Lola
524 Rolando Litzy
525 Francis Janessa
526 Ahmed Kailee
527 Ramiro Lilian
528 Trace Pamela
529 Will Trista
530 Ben Scarlett
531 Harry Ashanti
532 Warren Isis
533 Gilberto Kailyn
534 Jamarion Kali
535 Todd Kierra
536 Everett Laney
537 Malcolm Mckayla
538 Rocco Lexie
539 Ronnie Kaya
540 Izaiah Haylie
541 Jamie Irene
542 Addison Judith
543 Grady Krista
544 Adolfo Aspen
545 Kieran Janelle
546 Alonzo Karissa
547 Darian Araceli
548 Deshawn Zoie
549 Lincoln Gi

>>I'm sorry, I didn't realize I couldn't upload the exe file - but I have it ready to email.
That's ok We don't want you uploading exe files because (1) they can contain viruses and worms and (2) we can compile the code ourselves on our local computer to test it out.

line 13: you should declare that as std::string not char. What you declared is just one single character and I doubt very seriously that anyone would name their baby a single character.

line 29: like line 13 all you declared was a single character. Why read the file one character at a time when you could read it one word or line at a time.

I see that each line of that text file contains 3 words: a number indicating rank and two names. That means what you need to do is to create an array of structures that contain those three items.

struct line
{
     int rank;
     std::string name1;
     std::string name2;
};

now you can create an array of the above structures struct line names[1000]; Now to read those structures into the array

std::string name1, name2;
int rank;
int count = 0;
while(count < 1000 &&  in_put >> rank >> name1 >> name2)
{
    names[count].rank = rank;
    names[count].name1 = name1;
    names[count].name2 = name2;
    ++ count;
}

so should I delete what I've written and replace it with what you've typed? I'm not sure what to take out and what to leave in.

now I'm trying to get it to display some results, and it isn't working -

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;





int main()
{
    ifstream in_put;
    std::string enter_name;
    char data;
    
    in_put.open("babynames2004.txt");
    if (in_put.fail())
    {
       cout << "Input file opening failed.\n";
       exit(1);
    }
    
    cout << "Enter the first name that you would like to find the\n"
         << "popularity of from baby names in 2004.\n"
         << "Be sure to capitalize the first letter of the name.\n";
    cin >> enter_name
    


struct line
{
     int rank;
     std::string name1;
     std::string name2;
};

struct line names[1000];

std::string name1, name2;
int rank;
int index = 0, count = 0;
while(count < 1000 &&  in_put >> rank >> name1 >> name2)
{
    names[count].rank = rank;
    names[count].name1 = name1;
    names[count].name2 = name2;
    ++ count;
}

if (in_put = name1)
	cout << in_put << " is ranked " << rank <<  " in popularity among boys.\n";
else 
	cout << in_put << " is not ranked among the top 1000 boy names.\n";

if (in_put = name2)
	cout << in_put << " is ranked << rank << " in popularity among girls.\n";
else 
	cout << in_put << " is not ranked among the top 1000 girl names.\n";
    
    
    
    
    
    
    system("Pause");
    
    return 0;
    
}

lines 51 and 52: you can't use an ifstream (in_input) like that.

How do you distinguish boy names from girl names? Or is one colums boys and the other girls? After reading the file your program needs to scan through the list and count the number of times each name appears.

[edit]I went ahead and wrote the program (I'm not going to post it though). I found out that text file does not contain any duplicate names, unless of course my program is wrong. So I don't know how you can find the most popular girs and boys names [/edit]

This article has been dead for over six months. Start a new discussion instead.