header - Multiple Source File Problem in C++ -
i had a problem in implementing multiple source file
my function this:
inline bool textcontains(char *text, char ch) { while ( *text ) { if ( *text++ == ch ) return true; } return false; } void split(char *text, char *delims, vector<string> &words) { int beg; (int = 0; text[i]; ++i) { while ( text[i] && textcontains(delims, text[i]) ) ++i; beg = i; while ( text[i] && !textcontains(delims, text[i]) ) ++i; words.push_back( string(&text[beg], &text[i]) ); } } string convertint(int number) { stringstream ss; ss << number; return ss.str(); } string dateformatchecker(const char *date){ string strdate=date; char getdate[50]; strcpy_s(getdate, strdate.c_str()); vector<string> checkdate; split( getdate, "-", checkdate ); int year, month, day; year=atoi(checkdate[0].c_str()); month=atoi(checkdate[1].c_str()); day=atoi(checkdate[2].c_str()); string checkyear, checkmonth, checkday, checkhour, checkminute, checksecond; checkyear = convertint(year); if(month<10){ checkmonth = "0" + convertint(month); } else{ checkmonth = convertint(month); } if(day<10){ checkday = "0" + convertint(day); } else{ checkday = convertint(day); } if (checkyear.size() != checkdate[0].size()|| checkmonth.size() != checkdate[1].size()|| checkday.size() != checkdate[2].size()){ return ""; } return date; } string dateandtimeformatchecker(const char *dateandtime){ string strdate=dateandtime; char getdateandtime[50]; strcpy_s(getdateandtime, strdate.c_str()); vector<string> checkdateandtime; split( getdateandtime, "-: ", checkdateandtime ); int year, month, day, hour, minute, second; year=atoi(checkdateandtime[0].c_str()); month=atoi(checkdateandtime[1].c_str()); day=atoi(checkdateandtime[2].c_str()); hour=atoi(checkdateandtime[3].c_str()); minute=atoi(checkdateandtime[4].c_str()); second=atoi(checkdateandtime[5].c_str()); string checkyear, checkmonth, checkday, checkhour, checkminute, checksecond; checkyear = convertint(year); if(month<10){ checkmonth = "0" + convertint(month); } else{ checkmonth = convertint(month); } if(day<10){ checkday = "0" + convertint(day); } else{ checkday = convertint(day); } if(hour<10){ checkhour = "0" + convertint(hour); } else{ checkhour = convertint(hour); } if(minute<10){ checkminute = "0" + convertint(minute); } else{ checkminute = convertint(minute); } if(second<10){ checksecond = "0" + convertint(second); } else{ checksecond = convertint(second); } if (checkyear.size() != checkdateandtime[0].size()|| checkmonth.size() != checkdateandtime[1].size()|| checkday.size() != checkdateandtime[2].size()|| checkhour.size() != checkdateandtime[3].size()|| checkminute.size() != checkdateandtime[4].size()|| checksecond.size() != checkdateandtime[5].size()){ return ""; } return dateandtime; } string formatposdataxml (const char * sequencenumber, const char * retailstoreid, const char * workstationid, const char * businessdaydate, const char * begindatetime, const char * starttranstime, const char * endtranstime, const char * enddatetime, const char * rawdata){ string output; string bdd, bdt, stt, ett, edt; bdd = dateformatchecker(businessdaydate); bdt = dateandtimeformatchecker(begindatetime); stt = dateandtimeformatchecker(starttranstime); ett = dateandtimeformatchecker(endtranstime); edt = dateandtimeformatchecker(enddatetime); cout << "<transaction>\n\t<retailstoreid>" << retailstoreid << "</retailstoreid>\n\t<workstationid>" << workstationid << "</workstationid>\n\t<sequencenumber>" << sequencenumber << "</sequencenumber>\n\t<businessdaydate>" << bdd << "</businessdaydate>\n\t<begindatetime>" << bdt << "</begindatetime>\n\t<starttranstime>" << stt << "</starttranstime>\n\t<endtranstime>" << ett << "</endtranstime>\n\t<enddatetime>" << edt << "</enddatetime>\n\t<rawdata>" << rawdata << "</rawdata>\n</transaction>"; output = _getch(); return output; } string getinput(char *data){ vector<string> words; split( data, ",", words ); char sn[11], rsi[200], wsi[200], bdd[100], bdt[100], stt[100], ett[100], edt[100], rd[100]; strcpy_s(sn, words[0].c_str()); strcpy_s(rsi, words[1].c_str()); strcpy_s(wsi, words[2].c_str()); strcpy_s(bdd, words[3].c_str()); strcpy_s(bdt, words[4].c_str()); strcpy_s(stt, words[5].c_str()); strcpy_s(ett, words[6].c_str()); strcpy_s(edt, words[7].c_str()); strcpy_s(rd, words[8].c_str()); string posdata; posdata = formatposdataxml(sn,rsi,wsi,bdd,bdt,stt,ett,edt,rd); return posdata; }
but whenever put in header file :
string getinput(char *data);
i plenty of errors undeclared identifier, int string redefinition , on...
anyone can me?
i think order of header #includes might source of problem.
Comments
Post a Comment