paint by numbers code example
Example: PntIDNumbers
#include
#include
#include
#include
#include
#define MAX 200
using namespace std;
// Function receive address of the first element of an array
// Reads file contents and stores ID in the pointer
// Returns number of ID's read from the file using pass by reference
void readFromFile(string *idnumbers, int &counter)
{
// Opens the file for reading
ifstream readF;
readF.open("idnumbers.txt");
// Checks if the file unable to open for reading display's error message and stop
if(!readF)
{
cout<<"\n ERROR: Unable to open the file idnumbers.txt for reading.";
exit(0);
}// End of if condition
// Loops till end of the file
while(!readF.eof())
{
// Reads a ID from the file and stores in the pointer
readF>>*idnumbers;
// Increase the pointer by one to point to next address
idnumbers++;
// Increase the ID counter by one
counter++;
}// End of while loop
// Closer the file
readF.close();
}// End of function
// Function to display all the ID
void displayIDnumbers(string *idnumbers, int len)
{
cout<<"\n List of ID numbers: \n";
// Loops till number of ID
for(int c = 0; c < len; c++)
// Displays current ID
cout<<" "<> numYear;
// Checks if year is greater than 20
if(numYear > 20)
// Concatenates "19" before the year
dob = "19" + year;
// Otherwise year is greater then 20
else
// Concatenates "20" before the year
dob = "20" + year;
// Displays the date of birth
cout<<"\n Year born: "<