So im trying to convert this program, to use pointers and linked list. I really have not done anything with them so im here to ask for help!
Here to read and pop the array.
Code:
// Read names and pop
for (i=0; i < NUMNAMES; i++)
{
// input
in_stream >> popularity >> boyName >> girlName;
// store all data in array
boyNames[i] = boyName;
girlNames[i] = girlName;
}
in_stream.close();
Here is my array for search
Code:
// Search for name in arrays
boyPopularity = -1;
girlPopularity = -1;
for (i=0; i < NUMNAMES; i++)
{
if (boyNames[i] == targetName)
{
boyPopularity = i+1;
}
if (girlNames[i] == targetName)
{
girlPopularity = i+1;
}
}
Here is my output, would i need to rewrite this completely for use with pointers and linked lists?
Code:
// Output results if matched
cout << targetName << " is ";
if (boyPopularity > 0)
{
cout << "ranked " << boyPopularity << " in popularity among boys.\n";
}
else
{
cout << "not ranked among the top 1000 boy names.\n";
}
cout << targetName << " is ";
if (girlPopularity > 0)
{
cout << "ranked " << girlPopularity << " in popularity among girls.\n";
}
else
{
cout << "not ranked among the top 1000 girl names.\n";
}
system("PAUSE");
return 0;
}
So really im not sure what to do to start ive never used pointers before and would like some help converting what i have, thanks!