Linked Questions
96 questions linked to/from How to convert a std::string to const char* or char*
0
votes
2
answers
621
views
What is a call to `char()`, `uint8_t()`, `int64_t()`, integer `T()`, etc, as a function in C++? [duplicate]
I've never seen this call to char() as a function before. Where is this described and what does it mean? This usage is part of the example on this cppreference.com community wiki page: https://en....
-5
votes
2
answers
3k
views
hot to convert std::__cxx11::string to std::string [closed]
so i just want to convert int in digits and store it in array
for eg
int n=456;
std::string nstr = std::to_string(n);
std::cout << nstr[0];
now i just want the length of nstr...
whenever i ...
0
votes
4
answers
937
views
'MessageBoxA' : cannot convert parameter 2 from 'std::vector<_Ty>' to 'LPCSTR'
The following code works:
void CMyPlugin8::myMessageBox(std::string& myString)
{
myString = "Received the following string\n" + myString;
char * writable = new char[myString.size() + 1];
...
2
votes
6
answers
769
views
Needing to use char** in C++ instead of std::string*
I am working on an assignment for my operating systems class. We have the option of using C or C++, so I decided to use C++ since I practised it on the job a bit more recently than C.
I will need to ...
0
votes
2
answers
2k
views
Disappearing contents of std::vector<std::string>
I have a vector of strings which are changing its contents for no apparent reason. Can't really explain what is going on. Sorry for a long listing, but it's really bugging me.
I have a GUI ...
0
votes
4
answers
2k
views
convert from string to char* - passing function pointer
this post bases on the solution given here, a post on SO
I write a function to get a given file extension (string type), something like:
void GetFileExtension(string filename, char* extension)
{
...
-2
votes
2
answers
1k
views
Function to trim non, alphabetic, numeric characters from character array [closed]
I am looking to make a C++ function that has the following prototype:
char *trim(char *string)
What I want this function to do is the following:
Trim all the non, alphabetic, numeric characters
If ...
-4
votes
1
answer
2k
views
How to convert const *char to std::string [closed]
Im getting these errors because i cant convert correctly const char* to std::string....
In file included from ./../Header Files/MainGame.h:5:0,
from ./MainGame.cpp:2,
...
-4
votes
2
answers
3k
views
Converting std::string from const_iterator to char*?
I have an iterator of type:
std::map<int, std::string>::const_iterator
and as you can see the map is storing std::strings.
I am trying to extract a value using:
x.second.c_str()
and pass it ...
1
vote
2
answers
584
views
converting std::string to const char * and function calls
I have multiple methods inside my class which need const char * so I convert string to const char * inside the constructor of my class and store it in a local variable with type const char *. The ...
1
vote
2
answers
1k
views
error C2664: 'callToPrint' : cannot convert parameter 1 from 'std::wstring' to 'LPTSTR'
I converted a narrow string to the wide string as follows :
string nameOfPrinter;
getline( cin , nameOfPrinter );
wstring WprinterName;
int number = MultiByteToWideChar( CP_UTF8 , 0 , nameOfPrinter....
-3
votes
4
answers
1k
views
Can we swap char* with std::string
Is it legal to modify the result of std::string::op[]?
I would like to swap the contents of char* and std::string and could not do it. After going through the above link, I'm still unable to get the ...
1
vote
5
answers
990
views
Converting a string to char*
I am trying to write a function to convert a std::string to char* .
The first one I have written was this:
char* $ (string str)
{
char* cstr;
const unsigned int length=str.size();
cstr=...
0
votes
1
answer
1k
views
string <-> byte[] conversions
I'm implementing a system that uses libcrafter and crypto++ to transmit specific frames on the network. But the problem I'm stuck with isn't at this level at all.
It's about conversion between types ...
1
vote
4
answers
431
views
Converting string into const char *
Is there anything bad about the following code? Although it runs fine, but should I have allocated a memory to the character pointer first before initializing it?
const char *a;
string b;
getline(...