Re: string substr exception error

From: Hendrik Schober (SpamTrap_at_gmx.de)
Date: 02/17/04


Date: Tue, 17 Feb 2004 13:33:57 +0100

Jason Lee <jason74@tm.net.my> wrote:
> Dear All,
>
> I wonder anyone out there has try capture exception error of string
> substring,
> how do you really do in coding ?
>
> Well, I have try this, but it failed the capture the exception:
> [...]

  This prints "invalid string position"
  when compiled with VC7.1:

    #include <iostream>
    #include <exception>

    int main()
    {
      try {
        std::string a1;
        std::string a2 = a1.substr(1,2);
      } catch(const std::exception& x) {
        std::cerr << x.what() << std::endl;
      }
      return 0;
    }

> Jason Lee

  Schobi

-- 
SpamTrap@gmx.de is never read
I'm Schobi at suespammers dot org
"Sometimes compilers are so much more reasonable than people."
  Scott Meyers


Relevant Pages