Questions tagged [const-char]

68 questions
0
votes
0 answers

Should literal [const char*] be stored in one location?

Let's say, for example, you have a program that looks kinda like this: QJsonArray a = data->value("my_key").toArray(); a.push_back(id); data->insert("my_key", a); As you can see, the literal "my_key" is inserted twice. From my understanding, this…
Griffort
  • 1,174
  • 1
  • 10
  • 26
0
votes
1 answer

Sorting a vector

for ( fs::directory_iterator dir_itr2( out_folder ); dir_itr2 != end_iter; ++dir_itr2 ) { cout << "Path del file da inserire nel vettore:" << dir_itr2->path().string().c_str() << endl; …
0
votes
3 answers

Can't convert QString to Const Char*

I'm new to QT so please excuse me if I'm blatantly doing something wrong here, but I've looked at all the questions here on the matter but can't seem to find something that works. I'm trying to have the user create a folder by entering a name for…
user7733800
0
votes
1 answer

What's the effect of casting integer reference value to (const char*) and what's the difference between cast to char* and cast to const char* in c++?

I'm reading some codes where sometimes casting integer reference value to const char * used with ostream is happened. uint32_t val;// initialized by some value void a(ostream& os) const{ os.write((const char*)&val, sizeof(val)); } 1) What's…
mallea
  • 534
  • 6
  • 17
0
votes
1 answer

Experiencing an issue with the payload text in libcurl

The objective of my program is to send the contents of a text file automatically to an email address. While the sending works perfectly fine, the issue I am having is that I cannot seem to find a way to get the string "line", in which I have stored…
Ben Dover
  • 11
  • 3
0
votes
1 answer

Creating const char arrays in C++

so im trying to create an array with const char everytime the function is called i want to add to my array like a strtok so if i to wanted set struct R2R { private: int Index; const char* DvarA[10000]; const char*…
T.Shepherd
  • 13
  • 2
  • 6
0
votes
1 answer

String constructor of constant char* changes value of constant char*?

The Current Issue The value of a const char* seems to be changing to a nonsensical value. Faulty Code Example The intention of the code below is to create a string with the value of basedir. This process should keep the value of basedir constant;…
Zephyr
  • 27
  • 1
  • 5
0
votes
2 answers

How can I assign int values to const char array in my blackjack game, C

I'm working on a blackjack game in C. I have three functions, one to fill the deck, one for shuffling the cards and one for dealing the cards. My problem is that I don't know how to give my cards an integer value, I need that to see who wins. I…
Mallom
  • 47
  • 1
  • 6
0
votes
2 answers

Calculator 08 Buggy Program - Debug Issue

I am trying to solve the first exercise of Stroustrup's book about C++ programming principles. I'm pretty stuck with two issues. The first is that he says that there are three Compile-Time errors but I can see just one and, my second answer, is to…
0
votes
4 answers

std::cin >> *aa results in a bus error

I have this a class called PPString: PPString.h #ifndef __CPP_PPString #define __CPP_PPString #include "PPObject.h" class PPString : public PPObject { char *stringValue[]; public: char *pointerToCharString(); void setCharString(char…
user142019
0
votes
1 answer

IntelliSense: a member of type "const char *const []" cannot have an in-class initializer

Consider: class Note { public: // ... private: static const char* const NOTE_NAMES[12] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" }; } While it compiles fine, IntelliSense gave me an…
user3235674
0
votes
1 answer

What is the opposite of _bstr_t

I can easily convert a 'const char *' to 'BSTR' using BSTR bs = _bstr_t(myConstChar); This works fine. But I am not sure now to convert a BSTR to const char *. I don't know what the function (like "_bstr_t") for such a conversion would be.
tmighty
  • 10,734
  • 21
  • 104
  • 218
0
votes
1 answer

Char array size when using certain library functions

When using some library functions (e.g. strftime(), strcpy(), MultiByteToWideChar()) that deal with character arrays (instead of std::string's) one has 2 options: use a fixed size array (e.g. char buffer[256];) which is obviously bad because of the…
NPS
  • 6,003
  • 11
  • 53
  • 90
0
votes
2 answers

Adding a colon (:) to an unsigned char in C++

I am writing an Arduino library for simple data transfers between the Arduino and a computer using a serial feed. I have created the library, etc. However, I am having issues with taking a char array, and adding a colon (':') to it. That is, //Sends…
jacobsax
  • 37
  • 1
  • 7
0
votes
2 answers

Error LNK2001 while using my static library

I'm having LNK2001 issues while building my solution. The solution has 3 projects, one of them if just a main that returns 0, so I'll exclude it from the problem. One project (SerialPort) is a .lib that implements a class (SerialPort), while the…
joao figueiredo
  • 145
  • 1
  • 13