Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m reading a file with each line containing a date and a string. I am reading

ID: 3534620 • Letter: I

Question

I'm reading a file with each line containing a date and a string. I am reading the file line by line and using strtok to separate the line into tokens to assign the correct values. I believe I have the logic worked out, but when I try compiling, I am getting some errors. Thanks for any help.

Errors:

project.cpp: In function âvoid read_file(String, Vector<Chrono::Appointment>&)â:
project.cpp:21:28: error: cannot convert âStringâ to âchar*â for argument â1â to âchar* strtok(char*, const char*)â
project.cpp:24:20: error: invalid conversion from âchar*â to âintâ [-fpermissive]
/usr/include/ctype.h:113:1: error: initializing argument 1 of âint isalpha(int)â [-fpermissive]
project.cpp:26:24: error: invalid use of member (did you forget the â&â ?)
project.cpp:27:19: error: invalid use of member (did you forget the â&â ?)
project.cpp:28:27: error: invalid use of member (did you forget the â&â ?)
project.cpp:29:17: error: invalid use of member (did you forget the â&â ?)
project.cpp:30:24: error: invalid use of member (did you forget the â&â ?)

Code:

ifstream appointments ;
appointments.open( file_path ) ;
Chrono::Date date ;
string name ;
string line ;
char* foo ;
for ( int i = 0 ; !appointments.eof() ; i++ )
{
getline( appointments , line ) ;
foo = strtok( line, "/ " ) ;
while(foo != NULL)
{
if( !isalpha(foo) )
{
if ( date.month == 0 )
date.month = foo ;
else if ( date.day == 0 )
date.day = foo ;
else{ date.year = foo ; }

}
else{ name += foo ; }
foo = strtok( NULL, " /" ) ;

}

Format of the file:

1/1 New Year's Day

4/1 April Fool's Day

3/26/2013 Passover

4/15/2014 Passover

Explanation / Answer

www.dreamincode.net/forums/topic/218753-c-program-to