Questions tagged [const-char]
68 questions
0
votes
2 answers
How to use const char pointer returned from a function in this instance? (mongodb related)
I'm having a bit of trouble with a a function that the mongodb c driver uses. The function in question looks like this:
gridfile_get_field (gridfile *gfile, const char *name) (returns const char *)
I'm attempting to use it in the following…

the_man_slim
- 1,155
- 2
- 11
- 18
-1
votes
1 answer
Using a string in system() (maybe system_() )
my problem would be using a string in system(). As you might know you can use console commands in c++ with system() (or system_() if you realy want to :|) I want to make a simple Texteditor where the user can paste a filepath and then edit the file…

morigan
- 23
- 9
-1
votes
1 answer
Why can't my call to printf() display the right characters in console?
In visual studio, I can clearly see that the rstr() (to reverse string) function returns "olla\0", but the console display shows unreadable character symbols. Also, for some reason, after the call to printf(), the variable reverse transforms into…

Quoc-Minh
- 113
- 3
- 9
-1
votes
3 answers
C++: Program crashes when trying to print const char* array
I have a program that has a user enter their name, age, and the classes that they have taken. These classes are stored in the main() function as two-dimensional array of chars and then they are passed to a function within a Student class that copies…

jshapy8
- 1,983
- 7
- 30
- 60
-1
votes
1 answer
append const char variables wih string
I have 2 integers, whom I converted to const char* by passing to a user defined function. Now I want to append these 2 variables into a command line string as
"gnome-terminal -x sh -c 'cd; cd project/into_bot/; sh ./matlab_batcher.sh localize…

Lakshmi Narayanan
- 5,220
- 13
- 50
- 92
-2
votes
1 answer
strcmp can't convert char* to const char* in a prefix evaluation code (c++)
I'm writing a code to evaluate a prefix expression. The values of the expression are separated by spaces. So if the input is "+ * 87 89 666", I should get 8409 as the answer. The concept of my code is to store the values to an array and then…

Adrenno
- 23
- 1
-2
votes
2 answers
How to convert const unsigned char* payLoad to char* and copy it?
I'm trying to convert a const unsigned char* to char* as well as make a copy. I have tried several variations of the code below but I usually get a memory exception. This function resides in an application written in C.
The below function is what…

Jim
- 373
- 5
- 18
-3
votes
2 answers
Cout giving garbage output when looping through a const char
When executing the following code I get what I expect plus some unexpected output:
#include
using std::cout;
using std::endl;
int main()
{
const char ca[] = {'h', 'e', 'l', 'l', 'o'};
const char *cp = ca;
while (*cp)
{
…

Jinzu
- 1,325
- 2
- 10
- 22