Okay, part of my homework is to read from a logfile and output some specific information. (YES THIS IS HOMEWORK, AND NO, I DO NOT WANT YOU TO DO IT FOR ME! )
I would just like to know if it's possible to scan through a char array, and assign values to variables from it.
By the way, I haven't even tried to compile this yet, so I don't know if it even compiles. I'm pretty sure this won't work, as I'm passing fscanf() a char*, and not a FILE*.
Code:
void outputThings( char* line)
{
int day, hour, min, sec;
int ii;
char* month;
char* temp;
char* process = (char*)malloc(30*sizeof( char));
char* message = (char*)malloc(200*sizeof( char));
fscanf( line,"%s %d %d:%d:%d %s: %s", month, &day, &hour, &min, &sec, process, message);
printf("%s %d %d:%d:%d %s: %s\n", month, day, hour, min, sec, process, message);
}
As I said, I don't want you guys to do this for me, just tell me what function I should be using to scan the array, or tell me I'm going about it the wrong way.
thanks,
The Doctor