Linked Questions
96 questions linked to/from How to convert a std::string to const char* or char*
490
votes
18
answers
1.3m
views
std::string to char* [duplicate]
I want to convert a std::string into a char* or char[] data type.
std::string str = "string";
char* chr = str;
Results in: “error: cannot convert ‘std::string’ to ‘char’ ...”.
What methods are there ...
22
votes
7
answers
35k
views
How do I convert a string to a char* in c++? [duplicate]
I have an error in my program: "could not convert from string to char*". How do I perform this conversion?
27
votes
4
answers
52k
views
How to convert std::string to const char*? [duplicate]
Possible Duplicate:
Convert std::string to const char* or char*
void Foo::bar(const std::string& foobar) {
// ...
const char* foobar2 = (char*)foobar;
// ...
}
That does not work ...
18
votes
2
answers
141k
views
convert string to char* [duplicate]
Possible Duplicate:
Convert std::string to const char* or char*
Probably a & or something similar missing (I am noob at cpp).
I have
string R = "somthing";
char* S;
How would I copy R into ...
5
votes
3
answers
39k
views
Convert string to const char* issue [duplicate]
string str1 = "hello";
const char* string1 = str1;
I get an error..
cannot convert ‘std::string {aka std::basic_string}’ to ‘const char*’ in initialization
how do i cast string to const char*
...
5
votes
5
answers
9k
views
Write C++ string into char* [duplicate]
Possible Duplicate:
Convert std::string to const char* or char*
void setVersion(char* buf, std::string version) {
buf = version;
}
I'm trying to write the version string into the buf, but the ...
4
votes
3
answers
36k
views
How to convert an std::string to C-style string [duplicate]
I am programming in C++.
As basic as this question is I cannot seem to find an answer for it anywhere. So here is the problem:
I want to create a C-style string however I want to put an integer ...
3
votes
1
answer
23k
views
C++ No viable conversion from string to const char * [duplicate]
I'm using C++ (using CERN's ROOT framework) and I'm having a little problem with strings. I'm trying to label a histogram axis using a string defined by the user earlier in the code. Here are the ...
1
vote
3
answers
27k
views
How to convert std::string to const char in C++ [duplicate]
I tried to research this for a bit and I can't figure out the problem
Here's the code:
#include <iostream>
#include <stdlib.h>
#include <string>
void choose();
void newuser();
void ...
4
votes
3
answers
14k
views
Deep copy std::string::c_str() to char * [duplicate]
Currently I have a complex function that myself and our team are not wanting to refactor to utilize std::string and it takes a char* which is modified. How would I properly make a deep-copy of string::...
0
votes
3
answers
11k
views
Coverting std::String to char * [duplicate]
I need to pass string into socket send() function which accepts char * only. So here I am trying to convert it:
void myFunc(std::string str) //Taking string here const is good idea? I saw it on some ...
2
votes
4
answers
6k
views
Convert std::string to char * in c++11 [duplicate]
I am writing a library for mixed-languages and so we have to stick to a C interface. I need to call this API function:
void getproperty(const char * key, /* in */
char * value ...
2
votes
1
answer
1k
views
converting std::string to char * [duplicate]
Possible Duplicate:
Convert std::string to const char* or char*
I have a std::string and want to pass that as a file name to fstream like
std::string fname = "/home/mahmood/filter" + boost::...
2
votes
2
answers
2k
views
how to convert string to const char [duplicate]
so i got that first problem working. i run the code and i am prompt to enter some list into the array. after entering the list i run this function as a search_func. but it keeps return no record found....
0
votes
2
answers
2k
views
Mysql query string not working in query c++ [duplicate]
Hi I am having problems getting a string variable into my MySQL query I have tried everything I don't know where im going wrong any suggestions please.
string timestamp;
if (mysql_query(...