YCP Logo Lab 25: Baby Name Database

Due: Friday, Nov 7th by 11:59 PM

Getting Started

If you have a solution open in Visual Studio, close it (File->Close Solution).

Download CS200_Lab25.zip. Import it into Visual Studio (File->Import...).

Add your code to the source file called BabyNames.c.

Your Task

This is the input file:


Save it in the root folder of your H: drive.

Here is an example run of the program (user input in bold):

Input file: H:/babynames.txt
Name? Hubert
Male (M) or Female (F): M
Decade? 1900
In the 1900s, the name Hubert was ranked 122

Another run:

Input file: babynames.txt
Name? Harriet
Male (M) or Female (F): F
Decade? 1940
In the 1940s, the name Harriet was ranked 183

One more:

Input file: babynames.txt
Name? Cadwalader
Male (M) or Female (F): M
Decade? 1900
I did not find the name Cadwalader in the 1900s

Each line of the file represents the popularity of a particular name (male or female) in a particular decade of the 20th century. Here is the first line of the file:

1900 1 M John 84602

This line indicates that John was ranked number 1 for male baby names in the 1900s. (The last field is the number of babies recorded as named John in the 1900s.)

You can read an entire line of input from the file as follows:

int decade, rank, count;
char sex;
char name[200];


if (fscanf(in, "%i %i %c %s %i", &decade, &rank, &sex, name, &count) == 5) {
        /* one line from the file was read successfully */

This assumes in is a variable containing the file handle of the file you're reading from.

You can stop reading lines from the file once the file handle that is opened to read from the baby name database file has reached end-of-file. (I.e., when passing the file handle to the feof function returns a true value.)


When you are done, choose Tools->Submit to submit your completed lab to the server. You will need to enter your Marmoset username and password.

If the Tools->Submit option does not work, create a zip file containing the files in your project, and upload it to the submission server as lab25. The server URL is