I am writing my C ++ project and everything is fine in Visual Studio, but when I compile it on Ubuntu I am doing so many things get wrong. Example:
int main (int argsNum, char * args []) {country * country = new country ("USA"); Military Military * New Military ("Army", Country); Shalishoot * shalishut = new shalit (military); Manager * Manager = Manager :: GetInstance (); FileReader * fileReader = FileReader :: GetInstance (); FileReader-> ReadCityConfig (args, country); FileReader-> ReadRoadConfig (args, country); FileReader-> ReadMilitrayCampConfig (args, military); Military & gt; ShowBases (); Return 0; } Zero FileReader :: ReadMilitrayCampConfig (char * args [], military * military) {string line; Four inputfile names [MAX_FILE_NAME_LEN]; Strcpy (input filename, args [3]); Ifstream myfile (inputFileName); // inputFileName char * campName; String city name; If (myfile.is_open ()) {while (! Myfile.eof ()) {// file till the end of the getline (myfile, line); // Separate each line if ((line.size ()! = 0) & amp; amp; (Line [0]! = '#')) {CampName = strtok (& Line [0] , ","); Cityname = (string) strtok (NULL, ","); Shalishut :: FixName (campName); Shalishut :: FixName (& amp; cityName [0]); If (military-> isbasexist (campanam)) (if (military-> gtk- gatekeeper () - gt; isicixtist (name of city)) {base * base oad = new base (camp name, city name ); If (basostoyed! = Null) {Military-> Adbase Technology (BaseToyed); Military> GetCountry () -> FindCity (cityName) -> AddBaseToCity (baseToAdd);}} and cout & Lt; & lt; "Error: city name \" "
The problem is that the program reads cities and roads, but when I got the military camp read it:
"does not exist Can not add the base "Hazareim"!
Even though I have the basis in the same name in the config file. Snooze: It works perfectly in Visual Studio! error: the city name _____ does not exist, add the base "Hazratim" / Div>
I look carefully at the city's capitalization / spelling and the basis for the city. Do not eat.
In addition to strtok a std :: string is simply asking for trouble, because it is destructive and the expectation of the strings It is not that their internal situation is blown away randomly. There are methods like find_first_of to help you parsing c ++ strings
Comments
Post a Comment