• Register
1 vote


Hello Kodlogs,

I am going through a problem for the last few minutes. I tried to solve it in many ways but still couldn’t get rid of this. I’ve learning c++ programming language from last week. So, you can treat me as a novice in it.

I have a c++ program and I am trying to pass arguments through a function in it but it throws an error  c++ invalid conversion from const char* to char while I hit the run button.

Find my code snippet below and provide me a legit solution.

stringstream data;
char *addr=NULL;

And the function I tried to call:

void Printfunc(int a, char *loc, char *stream)

Thanks. Good day!

12 7 7
15,250 points

1 Answer

1 vote


As I can understand, retstring() is a function that returns a string. Before further proceeding check this.

However, your data.str().c_str() function produces a char const* but the function Printfunc()  wants char*s so, here comes the problem. In that case, you need to fix the declaration to solve the error.

Something like this:

void Printfunc(int a, char const* loc, char const* stream)

This should run fine, now. Give it a try and leave your feedback here.
Good day!

13 9 6
94,240 points

Related questions

0 votes
1 answer 2 views
0 votes
2 answers 151 views
Problem : Below is the wrong form: int &z = 12; Following is the correct form: int y; int &r = y; Question: Why is a first code wrong? What is a "meaning" of a below error? “Invalid initialization of non-const reference of type from an rvalue of type”
asked Jan 24 jwilliam 3.9k points
1 vote
1 answer 108 views
Problem: I am getting an error from my very simple c++ program. It says invalid conversion from int to int* What does it actually mean? Why I am experiencing this error? I am attaching my code snippet below. Please, check the code and fix the error if you can. ... } and the output I am getting is: invalid conversion from `int*' to `int' Many thanks for your effort and valuable time, guys.
asked Apr 8 Gavin 15.3k points
1 vote
1 answer 192 views
Problem: Hello Kodlogs, I find you guys very helpful and friendly alongside. You people are helping each other proactively. It&rsquo;s nice to see. I have a simple piece of code written in C++ that is producing an error passing as this argument discards qualifiers. I can smell something very ... < itr->getId() << " " << itr->getName() << endl; } return 0; } I must recognize your concern. Thanks.
asked Apr 16 Gavin 15.3k points