Linked Questions

7 votes
3 answers
821 views

string a = "asdf"; cout<<&a[0]; cout<<a[0]; Why are these two outputs different? Why is &a[0] not the address but the whole string?
celtspirit's user avatar
2 votes
3 answers
10k views

I am trying to convert a stringstream into a const char*, but I always get a blank string. My Code: #include<string> #include<sstream> #include<stdio.h> const char* test(std::...
Jan's user avatar
  • 433
3 votes
5 answers
6k views

I have this function and the compiler yells at me saying "Cannot convert string to const char". void DramaticLetters(string s, short TimeLength) { for(int i = 0, sLen = strlen(s); i < sLen; i+...
skittles sour's user avatar
2 votes
3 answers
4k views

I am getting an error when I run this piece of code string line; getline (myfile,line); char file_input[15]; strncpy(file_input, line, 6); cout << line << endl; Error - cannot ...
Vishal's user avatar
  • 999
-8 votes
1 answer
3k views

Here is my code: rename("tmp.png", Filename); The 2nd argument in the rename function is a string.(The user decides what the name is) How do I properly code this so that tmp.png is renamed to ...
Jarm Welch's user avatar
0 votes
2 answers
5k views

Trying to convert string to const char* gives "expression must have class type" at the bottom line. Tried some variations on converting with no luck. any ideas? string GetMachineID() { ...
michealbell's user avatar
1 vote
2 answers
3k views

the question as the title suggests, is an error when i was executing my program in the certain part of the password function. actually it is a basic password function which was working properly in ...
Shazin's user avatar
  • 13
0 votes
6 answers
3k views

I try to create a char* values[] for my unittests that will be written but initialized from constants. The naive way throws a warning that ISO C++ forbids it: char* single[1]; single[0] = "foobar"; I ...
aggsol's user avatar
  • 2,567
2 votes
3 answers
5k views

I'm trying to convert a string to an xmlChar. The compiler says no suitable conversion function from const string to xmlChar exists. This is what the code looks like: bool ClassName::openFile(const ...
Michele's user avatar
  • 3,936
1 vote
3 answers
1k views

I have two string declarations: killerName victimName I need to convert these two string values to const* char. Example of how I use my method: if (killer.IsRealPlayer) { killerName = killer....
user3281950's user avatar
3 votes
2 answers
2k views

I am now using C++ to program a robot using PROS. Pros has a print function, which is taking in a const char*. Now, I'm using lvgl to create my own screen, and I want to replicate the print function. ...
Eden Cheung's user avatar
1 vote
1 answer
7k views

I am working on a C++ project for a Vex Robot, I am using a function that takes a const char[] but for showing an integer, there is no such function that converts to const char[], so is there a way to ...
Coder436's user avatar
0 votes
3 answers
1k views

I have a function string_to_char() which attempts to give me a form of a string which I can pass into a library I am using, which wants char * (but I think works with const char *, so I've been trying ...
Joss's user avatar
  • 67
1 vote
2 answers
1k views

I am trying to store a char* into a struct's char* field. I have tried different things but none of them worked. The problematic piece of code is shown below: pInfo is the object of the struct ...
Sarvavyapi's user avatar
0 votes
2 answers
2k views

My question is why does the following code work hash<const char*> PassHash; cout << PassHash("Hello World"); But this code wont compile. hash<const char*> PassHash; string ...
ten ben's user avatar
  • 11

15 30 50 per page
1 2 3
4
5
7