Knowee
Questions
Features
Study Tools

/home/ubuntu/Main.cpp: In function ‘int main()’:/home/ubuntu/Main.cpp:7:35: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive] 7 | result = (m >= 6.0 && s >= 50.5) ? "Eligible for Next Round" : (m < 6.0 || s < 50.5) ? | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | const char* 8 | "Not Eligible" : "Try again..."; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Question

/home/ubuntu/Main.cpp: In function ‘int main()’:/home/ubuntu/Main.cpp:7:35: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive] 7 | result = (m >= 6.0 && s >= 50.5) ? "Eligible for Next Round" : (m < 6.0 || s < 50.5) ? | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | const char* 8 | "Not Eligible" : "Try again..."; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

The error message you're seeing is due to trying to assign a const char* to a char*. In C++, string literals are of type const char*, which means they are read-only. If you try to assign them to a char*, you're implying that you might change the string, which is not allowed.

Here's how you can fix this:

  1. Change the type of result to const char*. This will match the type of the string literals you're assigning to it.

This problem has been solved

Similar Questions

home/ubuntu/Main.cpp: In function ‘int main()’:/home/ubuntu/Main.cpp:60:13: error: ‘exit’ was not declared in this scope 60 | exit(0); | ^~~~

/home/ubuntu/Main.cpp: In function ‘int evaluateexpression(char*)’:/home/ubuntu/Main.cpp:29:12: error: ‘isdigit’ was not declared in this scope 29 | if(isdigit(token[0])){ | ^~~~~~~

Compiler Message/home/ubuntu/Main.cpp:20:20: warning: missing terminating " character 20 | printf("Invalid type entered! | ^/home/ubuntu/Main.cpp:20:20: error: missing terminating " character 20 | printf("Invalid type entered! | ^~~~~~~~~~~~~~~~~~~~~~/home/ubuntu/Main.cpp:21:1: warning: missing terminating " character 21 | "); | ^/home/ubuntu/Main.cpp:21:1: error: missing terminating " character 21 | "); | ^~~/home/ubuntu/Main.cpp:27:20: warning: missing terminating " character 27 | printf("Integer: %d | ^/home/ubuntu/Main.cpp:27:20: error: missing terminating " character 27 | printf("Integer: %d | ^~~~~~~~~~~~/home/ubuntu/Main.cpp:28:1: warning: missing terminating " character 28 | ", *(int*)value); | ^/home/ubuntu/Main.cpp:28:1: error: missing terminating " character 28 | ", *(int*)value); | ^~~~~~~~~~~~~~~~~/home/ubuntu/Main.cpp:31:20: warning: missing terminating " character 31 | printf("Float: %.2f | ^/home/ubuntu/Main.cpp:31:20: error: missing terminating " character 31 | printf("Float: %.2f | ^~~~~~~~~~~~/home/ubuntu/Main.cpp:32:1: warning: missing terminating " character 32 | ", *(float*)value); | ^/home/ubuntu/Main.cpp:32:1: error: missing terminating " character 32 | ", *(float*)value); | ^~~~~~~~~~~~~~~~~~~/home/ubuntu/Main.cpp: In function ‘int main()’:/home/ubuntu/Main.cpp:22:13: error: expected primary-expression before ‘return’ 22 | return 0; | ^~~~~~/home/ubuntu/Main.cpp:29:13: error: expected primary-expression before ‘break’ 29 | break; | ^~~~~/home/ubuntu/Main.cpp:33:13: error: expected primary-expression before ‘break’ 33 | break; | ^~~~~Sample TestcaseTestcase 1 - FailedExpected OutputInteger: 4OutputTestcase 2 - FailedExpected OutputFloat: 5.50OutputTestcase 3 - FailedExpected OutputInvalid type entered!

./Solution.cpp: In function 'int main()':./Solution.cpp:30:5: error: redefinition of 'int main()' int main() { ^./Solution.cpp:16:5: note: 'int main()' previously defined here int main() {

/home/ubuntu/Main.cpp:3:15: error: expected unqualified-id before ‘int’ 3 | char register(int weight, double height) { | ^~~/home/ubuntu/Main.cpp:3:15: error: expected ‘)’ before ‘int’ 3 | char register(int weight, double height) { | ~^~~ | )/home/ubuntu/Main.cpp: In function ‘int main()’:/home/ubuntu/Main.cpp:30:16: error: expected primary-expression before ‘register’ 30 | category = register(weight, height); | ^~~~~~~~

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.