int parse_command_line (char commandLine[MAX_INPUT_LINE_LENGTH], char* cmds[MAX_CMDS_NUM]){
char delims[] = "|";
char *result = NULL;
result = strtok( commandLine, delims );
int count = 0;
if((logfp=fopen("LOGFILE", "w"))==NULL)
{
perror("Error");
exit(1);
while( result != NULL ) {
fprintf(logfp, "cmd[%d] will point to string \"%s\"\n", count, result);
count=count+1;
result = strtok( NULL, delims );
}
fclose(logfp);
//exit(1);
}
fprintf 语句放置由分隔符“|”终止的行 进入日志文件。我希望该值也存储在一个数组中,我可以在接下来的过程中访问该数组。每次将一行添加到 LOGFILE 时,我都需要数组中的该值。