View Poll Results: Will I ever be able to get this function working good?

Voters
2. You may not vote on this poll
  • sure thing buddy!

    1 50.00%
  • No way! you suck too much..

    0 0%
  • bah, who cares?

    1 50.00%

Thread: istringstream.get me something!!

  1. #1
    Burning in Hell! Luigi's Avatar
    Join Date
    Nov 2002
    Posts
    117

    istringstream.get me something!!

    In the main function a call for this function get_token() and within it i use a global var/input ist.get..

    Ist is previously declared outside the main like this : istringstream ist(temp_string);

    temp_string is a c++ string

    Code:
    Token_value get_token()
    {
          char ch = 0;
          do	// skip whitespace except '\n'
          {
    	  if(!ist.get(ch)) return curr_tok = END;
          }while(ch != '\n' && isspace(ch));
          switch (ch)
          {
    	  case 0 : //...etc
    My problem is that ist.get(ch) WONT get anything?
    when ist was declared within get_token it would work but now it just dont?

    I dont get it..
    any comment/sugestion/answers appreciated..

    here is the full code just in case..
    Luigi


    // I use Xcode 1.1 && CodeWarrior 8.3
    // When on Mac Os X 10.3.2

    // I use Microsoft Visual C++ 6.0
    // When on windows XP

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    You shouldn't be initalising the stringstream outside of a function if you are using another variable to inialise it. Try making it a stringstream, and using the << operator to put the value of temp_string into it.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Burning in Hell! Luigi's Avatar
    Join Date
    Nov 2002
    Posts
    117
    I tried that xsquared but it didnt work..
    I really dont know why if I put cin.get it will work but ist.get just wont do it...

    Luigi


    // I use Xcode 1.1 && CodeWarrior 8.3
    // When on Mac Os X 10.3.2

    // I use Microsoft Visual C++ 6.0
    // When on windows XP

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    I think its probably a problem with the way you initalize the stringstream.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  5. #5
    Burning in Hell! Luigi's Avatar
    Join Date
    Nov 2002
    Posts
    117
    hmm ok how then?
    I tried to init it inside get_token() just like u said but same problem..

    If u compile it do you have the same problem?
    Im asking to be sure that the problem is not my compiler..

    This is driving me nuts.. stuck at the same point for a very long time..
    Luigi


    // I use Xcode 1.1 && CodeWarrior 8.3
    // When on Mac Os X 10.3.2

    // I use Microsoft Visual C++ 6.0
    // When on windows XP

Popular pages Recent additions subscribe to a feed