Jump to content



Recommended Posts

Hmmm not really what im after say i have "string x" and x=snakey how do i use the a as a seperate string. So i'll have int x = snakey then i'll make int y which will = a.

P.S. i dont no what x is at the start it gets entered as an input and i use each letter individually if that helps any.

Link to comment
Share on other sites

I'm sure there's a built in function for it, I have done it in Java, but not C++, sorry.

    string str1( "Alpha Beta Gamma Delta" );
    unsigned int loc = str1.find( "Omega", 0 );
    if( loc != string::npos )
      cout << "Found Omega at " << loc << endl;
      cout << "Didn't find Omega" << endl;

That does what you want on the side... just change the "Omega" to the character, and use the character position that is returned to substring(Java) whatever you want out.

Read under the "find" command here:


Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...