Invalid Conversion From Const Char To Char Dev C++

08.06.2020by
  1. How To Convert Const Char To Char

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. Nice that was quite helpful. Although the function that i mentioned above MyFunction(MyChar) takes in a char value. I cannot pass it a MyChar value because it complains for invalid conversion from char to.char. So i did MyFunction(&MyChar) and it compiles but it inputs malicious data.this is what it inputs: a y ab.

Hey Guys. Im having a hard time figuring this out. I realize there are a bunch of topics out there discussing this problem but I couldn't find anything that was helpful to this particular situation.

Its giving me the errors:
prog.cpp: In function ‘int main()’:
prog.cpp:15: error: incompatible types in assignment of ‘char’ to ‘char [4]’
prog.cpp:16: error: invalid conversion from ‘char’ to ‘const char*’
prog.cpp:16: error: initializing argument 2 of ‘char* strcpy(char*, const char*)’

Invalid

My goal is to somehow copy the elements of the array to MyChar to use it later. Any suggestions would be much appreciated. Thanks.

Crack

Char
  • 3 Contributors
  • forum 10 Replies
  • 1,218 Views
  • 19 Hours Discussion Span
  • commentLatest Postby UberJokerLatest Post

Narue5,707

MyChar is an array of char. a is a single char. The two types are completely incompatible. MyChar[i] = a[i] would work. At least until i gets incremented past 1, then you're accessing a out of bounds.

morning everyone.
i hope someone out there could really help me.
im trying to store large numbers. as i need to complete my work under Dev-c++ environment but im not familiar with it as i just started using it recently.
the following is my initial coding for my work.

after i compile using Dev-C++, it shows this error description:
invalid conversion from 'char' to 'const char*'
initializing argument 1 of 'int atoi(const char*)'
i've tried all ways to modify my coding but i just cant get it.
really would be happy if someone could help me.
hope to receives some replies as soon as possible.thank you.

  • 4 Contributors
  • forum 5 Replies
  • 978 Views
  • 2 Days Discussion Span
  • commentLatest Postby pearlyLatest Post

Ancient Dragon5,243

How To Convert Const Char To Char

My guess is the problem is in stack2.cpp. But since you did not post it there is no way to tell. Also please post the exact error message including file and line number

Comments are closed.