封装 //2010-3 Single //get fields of one row from a char* str comparted by the compart char //the parameter str should not be a const char* str //eg. //char str[1024] = "my-name-is-HanMeimei"; //char seg = '-'; //GetLineFromStr(str, seg); long OciTable::GetLineFromStr(char* str, char seg) { char* phead = str; char* ptail = str; int ipos = 0; while (*ptail != '/0') { if (*ptail == seg) { if (ptail != phead) { *ptail = '/0'; if ((tfields[ipos])->dtype == SQLT_FLT) { *(tfields[ipos]) = atof(phead); } else if ((tfields[ipos])->dtype == SQLT_INT) { *(tfields[ipos]) = atol(phead); } else { *(tfields[ipos]) = phead; } } phead = ptail + 1; ipos++; //in case the number of fields in the str is more than the table's, make the process more safe if (ipos == fnum) { ptail++; break; } } ptail++; } if (ptail != phead) { *ptail = '/0'; if ((tfields[ipos])->dtype == SQLT_FLT) { *(tfields[ipos]) = atof(phead); } else if ((tfields[ipos])->dtype == SQLT_INT) { *(tfields[ipos]) = atol(phead); } else//SQLT_STR { *(tfields[ipos]) = phead; } } Insert(); return 1; } 注意date命令 date -d yesderday date -d tomorrow 可以这样使用,用来判断当前时间是不是月末,date -d tomorrow 为01 ,则表示是月末