i am stuck on this assignment, i am a newbie just started learning c and i can't seems to figure out how to finish this.
This is what i have so far, i have been sitting for the whole night and still trying, help me please....thanks
----------------------------
A program that will read a set of names and dates from the command line; format the names and display the person’s age.
Input
At the command line the user will enter zero or more strings. The strings will include names and dates. The names are always first and last, and the dates are always in the format mm/dd/yyyy. The program will support several command line arguments, shown below:
-f
Display each name with the first letter of each name capitalized, and the remaining letters lower-case
-l
Display only the last name
-y
Display age in years
-h
Help; not supported with the other options
A sample session is shown below:
c:> hw6 -fn john smith 10/01/1965 malik kaleel 3/01/1954
The user may not enter any strings, at which time your program will display a help message (of your choice) and terminate.
Output
Continuing the previous example, you will output the following:
Student Age
---------- ---------
Smith, John 35.58
Kaleel, Malik 47.17
The age is the person’s actual age. For example Malik, in the example above is 47 years and 2 months, thus 47 + 2/12. If the ‘y’ argument was provided you would only display “47”. If no strings are provided, simply display the header information, and display a help message. You will also display help, if the user enters an incorrect argument (an argument is a single character preceded by an '-').
Functions
Your program must provide the following functions:
You will code the following functions:
1. int getDOB(char * cpDOB, int * ipMonth, int *ipDay, int * ipYear); given a date of birth as a string (cpDOB [mm/dd/yyyy], determine the month, day, and year; return 1 if successful, 0 if failed; fails if the format is incorrect, or if the date is invalid
2. int formatName(char * cpFirstName, char * cpLastName, char * cpFullName); creates a full name, in the form, <LAST, FIRST>, i.e. “Smith, John”; returns 1 if successful, 0 if failed
3. void howTo(); display help info on how to correctly use the program; include bonus info if you complete the bonus options (see below)
Bonus
5 pts add another argument (-r) that will display the person’s year of retirement (add a column to the display)
10 pts; add an argument (-p) which will create a random password and display the passwords (add a column to the display); the password should be 8 characters, and include both alphabets, numbers.
-----------------------------------------
#include <stdio.h>
#include <time.h>
#define SWITCH '-'
#define FLCAPITALIZED 'f'
#define LASTNAME 'l'
#define YEARS 'y'
#define HELP 'h'
int getDOB (char * cpDOB, int * ipMonth, int * ipDay, int * ipYear);
int formatName (char * cpFirstName, char * cpLastName, char *cpFullName);
void howTo ();
void DisplayHeader ();
void main (int argc, char * argv []) {
int i = 0;
int j = 0;
char cSwitch;
char cOption1;
char cOption2;
char cOption3;
cSwitch = * (argv [1]);
cOption1 = * (argv [1] + 1);
cOption2 = * (argv [1] + 2);
cOption3 = * (argv [1] + 3);
if (argc > 1) {
if ((cOption1 == FLCAPITALIZED) || (cOption2 == FLCAPITALIZED) || (cOption3 == FLCAPITALIZED)) {
}
if ((cOption1 == LASTNAME) || (cOption2 == LASTNAME) || (cOption3 == LASTNAME)) {
printf ("Students by last name only\n");
printf ("----------\n");
printf ("%s\n", argv[3]);
}
if ((cOption1 == YEARS) || (cOption2 == YEARS) || (cOption3 == YEARS)) {
}
}
else if (argc == 1) { //display help screen if no string enter
howTo();
}
}
void howTo () {
printf("Help Screen\n");
printf("------------\n\n");
printf("c:> hw6 [options] [string1] [string2] [string3]..........\n\n");
printf("-f\tDisplay each name withthe first letter of each name capitalized, and the\tremaining letter lower-case\n");
printf("-l\tDisplay onlu the last name\n");
printf("-y\tDisplay age in years");
printf("-h\tHelp; not supported with the other options\n");
}