Results 1 to 6 of 6

Thread: CString bob = stl::string fred problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Location
    Uppsala
    Posts
    2

    Question CString bob = stl::string fred problem

    I have a silly question.

    How do I convert a STL string to a MFC CString in an elegant way?

    using namespace std;
    CString bob;
    string fred;

    bob = fred; // Deos not work, duh!


  2. #2
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    I would imagine:
    Code:
    std::string x = "Hello";
    CString y = x.c_str();
    Z.

  3. #3
    Addicted Member BarankinBeAMan's Avatar
    Join Date
    Aug 2002
    Location
    Reston,Va
    Posts
    164

    Unhappy std in MFC exe

    How come I can't get std::string get to work in
    my MFC dialog based exe ?
    If I use std::string in my class,
    I get error :


    'std' : is not a class or namespace name
    'string' : undeclared identifier

    using namespace does not help either .

    What's up with me ?

  4. #4
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Probably didnt include <string>.

    Z.

  5. #5
    Addicted Member BarankinBeAMan's Avatar
    Join Date
    Aug 2002
    Location
    Reston,Va
    Posts
    164
    Nope, not that, still does not work

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Maybe you included <string> before "stdafx.h". The compiler ignores any code prior to this include if activated.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width