• 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

Please log in or register to answer this question.

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,260 points

Related questions

0 votes
1 answer 8 views
Problem: How to fix, error: invalid conversion from const char* to char [-fpermissive] ?
asked Apr 15 Humaira ahmed 50.7k points
0 votes
1 answer 3 views
Problem: There's a bunch of threads about C++, but I'm stuck with regular C here and can't find an answer anywhere. I'm getting errors as the title states. 13 25 ~ [Error] invalid conversion from 'char' to 'const char*' [-fpermissive
asked Apr 13 ummesalma 29.2k points
0 votes
1 answer 47 views
Problem: I get the error invalid conversion from 'const char*' to 'char*'. initializing argument 3 of 'void Printfunc(int, char*, char*)'on argument 3 of the function on the above line. The function is called as shown below void Printfunc(int a, char *loc, char *stream) please let me know if I need to change any initialization.
asked Dec 27, 2020 Mashhoodch 13k points
0 votes
1 answer 6 views
Problem: Hi there! I want to know that is there any way to declare a function that could take a variable number of arguments of the same type? I want something like follows: function(int arg1, arg2, ….) {} If there is such a mechanism, how can it be used? Please give an example. Thanks!
asked Mar 28 Code Learner 9.8k points
0 votes
1 answer 14 views
1 vote
1 answer 4 views
Problem: How can I deal with this problem : invalid conversion from 'const char*' to 'char' [-fpermissive]
asked Apr 8 MUHAMMAD MUNEEB 83k points
0 votes
1 answer 7 views
Problem: Hello! I am a beginner and I am trying to get some hands-on practice for functions in C++. I have written the following program in which I have declared a function that takes three parameters: #include<iostream> using namespace std; int func_1(int var1, ... . Please help me identify the error and resolve it. Please mention the changes that are to be made to resolve the error. Thanks!
asked Apr 17 Code Learner 9.8k points
0 votes
1 answer 32 views
Problem: Hello! I am a noob. I came to know about optional parameters in C++. My concept of optional parameters is not clear. Moreover, I read somewhere that in a function definition, an optional parameter must be placed first in the argument list. Is this true? Can anybody explain the concept of default arguments to me? Thank you.
asked Dec 4, 2020 Code Learner 9.8k points
1 vote
1 answer 556 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, 2020 Gavin 15.3k points
0 votes
1 answer 11 views
Problem: What is a const member function in C++? What is the syntax of a const member function? How do you declare a constant in C++? What does const after a function mean?How member function can be called on a const object (or via a reference-or-pointer-to-const), and that the member function cannot modify data members (unless they're marked mutable ?
asked Dec 23, 2020 Mashhoodch 13k points