Linked Questions

489 votes
18 answers
1.3m views

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 ...
user avatar
22 votes
7 answers
35k views

I have an error in my program: "could not convert from string to char*". How do I perform this conversion?
Ptichka's user avatar
  • 295
27 votes
4 answers
52k views

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 ...
Richard Knop's user avatar
  • 84.2k
18 votes
2 answers
141k views

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 ...
Itay Moav -Malimovka's user avatar
5 votes
3 answers
39k views

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* ...
user1777711's user avatar
  • 1,764
5 votes
5 answers
9k views

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 ...
Terry Li's user avatar
  • 17.3k
4 votes
3 answers
36k views

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 ...
user1413793's user avatar
  • 9,427
3 votes
1 answer
23k views

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 ...
khfrekek's user avatar
  • 211
1 vote
3 answers
27k views

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 ...
user avatar
4 votes
3 answers
14k views

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::...
Nick Betcher's user avatar
  • 2,046
0 votes
3 answers
11k views

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 ...
Catty's user avatar
  • 466
2 votes
4 answers
6k views

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 ...
user avatar
2 votes
1 answer
1k views

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::...
mahmood's user avatar
  • 25.2k
2 votes
2 answers
2k views

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....
user618879's user avatar
0 votes
2 answers
2k views

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(...
n4zg's user avatar
  • 397

15 30 50 per page
1
2 3 4 5
7