Find the answer to your Linux question:
Results 1 to 6 of 6
Hi All, I have a problem with wstring, maybe someone had similar problem. When I trying to create wstring object: std::wstring testString(L"Simple string"); created object testString have invalid length, i.e. ...
  1. #1
    Just Joined!
    Join Date
    Sep 2009
    Posts
    6

    [SOLVED] std::wstring problem in simple program

    Hi All,
    I have a problem with wstring, maybe someone had similar problem.
    When I trying to create wstring object:

    std::wstring testString(L"Simple string");
    created object testString have invalid length, i.e. when I get length after creating object:
    testString.length()
    it returns some dummy number (thousands, millions). I programming under Ubuntu, and my gcc version is 4.3.3.
    I'm new in Linux programming. I know that it is need to post code to the forum when asking the question, but the problem is so simple, that it is nothing to post, just main function, and object of wstring type.
    It is interesting that with std::string object everything is ok. Even if I create wstring object with empty string
    std::wstring emptyString(L"")
    object also have invalid length, emptyString.clear() - also doesn't help.

    I will be very thankful for any help in this issue.

    P.S. sorry for grammatical and syntax errors, English is not my native language.

  2. #2
    Just Joined!
    Join Date
    Sep 2009
    Posts
    6
    Thanks to all, question closed!

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    So, what was your solution?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  4. #4
    Just Joined!
    Join Date
    Sep 2009
    Posts
    6
    It was very stupid thing...
    I use NetBeans, and it is possible to watch expressions like: "someString.length()" in Watch window in process of debug, and you get some value, but actually it shows pointer on function in decimal form, but not value returned by this function...

    Yes, I know, I stupid...
    Anyway, thank you for your help and your time.

  5. #5
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Quote Originally Posted by AndrewY View Post
    It was very stupid thing...
    I use NetBeans, and it is possible to watch expressions like: "someString.length()" in Watch window in process of debug, and you get some value, but actually it shows pointer on function in decimal form, but not value returned by this function...

    Yes, I know, I stupid...
    Anyway, thank you for your help and your time.
    Yeah. I've made that mistake once or twice in the (distant) past... Glad you figured it out.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  6. #6
    Just Joined!
    Join Date
    Sep 2009
    Posts
    6
    yea... I thought NetBeans will display "Invalid watch expression" or something like that... But pointer to function in decimal form, without any hints, it's cruel , but, anyway it's my fault.

    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...