Thread: strcpy aaarrrrgggghhhh

  1. #1
    Registered User
    Join Date
    Sep 2002

    strcpy aaarrrrgggghhhh

    Tokenise line from file into vector with the following and am trying to copy vector values to variables - have tried EVERYTHING c_str()
    And have NO idea what is happening. Have noted all that have tried in below code. Any ideas??? The error msg is:
    cannot convert std::string to char* strcpy(char*,const char*)

    void Tokenize(const string& str,
                          vector<string>& tokens,
                          const string& delimiters = "/n")
        // Skip delimiters at beginning.
        string::size_type lastPos = str.find_first_not_of(delimiters, 0);
        // Find first "non-delimiter".
        string::size_type pos     = str.find_first_of(delimiters, lastPos);
        while (string::npos != pos || string::npos != lastPos)
            // Found a token, add it to the vector.
            tokens.push_back(str.substr(lastPos, pos - lastPos));
            // Skip delimiters.  Note the "not_of"
            lastPos = str.find_first_not_of(delimiters, pos);
            // Find next "non-delimiter"
            pos = str.find_first_of(delimiters, lastPos);
    void loadTeams(char *line,string countryName,string code)
    	string temp;
    	vector<string> teamTokens;
    	std::vector<string>::const_iterator p;
    	Tokenize(line, teamTokens,"|");
    This compiles but doesnt work 
            Team* pTeam1 = new Team();
      This compiles but doesnt work   
    This doesnt compile    

  2. #2
    Registered User
    Join Date
    Oct 2001
    >void loadTeams(char *line,string countryName,string code)

    To return values in strings, pass them by reference:
    void loadTeams(char *line,string &countryName,string &code)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A Full Program to analyze.
    By sergioms in forum C Programming
    Replies: 2
    Last Post: 12-30-2008, 09:42 AM
  2. Strcpy
    By Godders_2k in forum C Programming
    Replies: 17
    Last Post: 12-12-2007, 12:34 PM
  3. Where is strcpy() defined? (Can't find in string.h ect)
    By Zero_Point in forum C++ Programming
    Replies: 6
    Last Post: 04-03-2006, 05:14 PM
  4. Question about strcpy
    By Kevinmun in forum C Programming
    Replies: 4
    Last Post: 11-02-2005, 11:00 PM
  5. strcpy
    By Luigi in forum C++ Programming
    Replies: 17
    Last Post: 02-16-2003, 04:11 PM