Bernt Warholm
Bernt Warholm

Reputation: 13

convert a string into cstring

I am trying to convert my string to a cstring in an mfc Application. I have searched this forum for hours without any result.

my code is:

void CSokevinduView::OnBnClickedsoker()
{
string O1,O2,O3,info;


ifstream Innfil;
Innfil.open("SQLPResponse.txt");
Innfil.ignore();
getline(Innfil,O1);
getline(Innfil,O2);
getline(Innfil,O3);
getline(Innfil,info);
Innfil.close();

    m_sok=info;

m_sok is a cstring btw.

The problem is that "m_sok" dont want to be like "info".

I am very New to this as you can see from my coding.

Thx in advance.

Upvotes: 1

Views: 184

Answers (1)

Joseph Willcoxson
Joseph Willcoxson

Reputation: 6040

Use the c_str() method of string.

m_sok = info.c_str();

Upvotes: 1

Related Questions