Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Help on vectors

This topic is 5421 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

help help help:::: i wrote this fuction to strip down a char array and put the different parts vector and to take out the delimitor, i think it works but when i try to get a part out of the vector (below) it does not like it, im a complete c++ dummy so it probably realy easy vector cGame::Token() { char delimitChar[] = "#"; char *buffer_token; vector token_vector_buffer; // imcomming message in vector char CharInBuffer[MAX_MESSAGE_SIZE]; // imcomming message in array of cahrs string StrInBuffer; // imcomming message in a string strcpy(CharInBuffer, StrInBuffer.c_str()); StrInBuffer = pNetwork->Network_Recieve(); //listening from network code cout << "Token fuction incomming : StrInBuffer" << endl; //Establish string and get the first token: buffer_token = CharInBuffer; buffer_token = strtok( CharInBuffer, delimitChar ); while( buffer_token != NULL ); { // While there are tokens in "string" token_vector_buffer.push_back(buffer_token); // Get next token: buffer_token = strtok( NULL, delimitChar ); } return token_vector_buffer; } ---------------------------------------- this is the part that in another fuction, i need to take out the 2nd elment of the vector and compare it to 1 vInBuffer = Token(); //run token function and send back vector cout << "Incomming from Token fuction : vInBuffer" << endl; if vInBuffer[1] == "1"; { cout << "Register sucsessful" << endl; StartMainMenu(); } else { cout << "Please enter your information again" << endl; } ----------------------------------------- any help would be good cheers

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!