0

Error: Invalid conversion from const char* to char -fpermissive How to fix this?

https://code.sololearn.com/c6chuoNE97ic/?ref=app switch (place) { //If place == 'a' case 'a': //Juliens Wreck, Sipalay City cout <<"\nJuliens Wreck, Sipalay City\n"; cout << "Distance - 163 km\n"; place [] ={"Wreck, Sipalay City"}; break; I also tried this but it says expected token before ] if the user choose five different places... and if they choose 1 vehicle we should prompt the user to enter the day trips they want so if all of the five places it will be conflict maybe we calculate each places first one by one like example place 1 has a distance of 20 km place 2 has a distance of 163 km place 3 .... 50 km calculate each of the distance first before adding all the expenses Or maybe the code must prompt the user first for the first selection then the second choice then the third and so on I get stuck at this I don't know please solve

5th Dec 2021, 2:42 AM
shlee_
shlee_ - avatar
35 Respostas
+ 3
šŸ˜³ā˜ŗļø in C++ switch is used only with integer values. I was surprised that you have written more than 200 lines of code and have never tested it for performance.
5th Dec 2021, 3:24 AM
Solo
Solo - avatar
+ 3
Shlee_, As I said before, you have a big code, and I'm on a phone, it's hard to read big code in a phone. So, it's not like I don't wanna help, but seriously, I have no idea what you want this code to do. Also if possible, learn code indentation. C++ doesn't mind indentation as much or as strictly as Python, but indentation definitely helps improve code readability : )
5th Dec 2021, 3:35 AM
Ipang
+ 3
Okay, so mutiiple destination choice is allowed. But how to manage that? I mean what if a user chooses 3 destination, but only reserve for 2 days trip. Does that make sense?
5th Dec 2021, 2:09 PM
Ipang
+ 3
That's not much of an issue, we'll think of something. I'm more concerned with time management, like what to do where user choose 3 destinations but only reserve 2 day trips. I'm concerned because the calculation is based on number of days ... Or ... number of destination must match reserved days? * I'm definitely removing my comments now, too many ...
5th Dec 2021, 2:20 PM
Ipang
+ 2
Maybe your best bet is to contact the author of this code, Ashlie?
5th Dec 2021, 3:12 AM
Solo
Solo - avatar
+ 2
<place> is defined as `char` at line 10 char place = 'a'; But you try to assign constant char* (constant C-string) for variable <place> on the following lines 51, 60, 68, 76, 84, 92, 100, 108, 115 and 123 A `char` variable can only store 1 byte (character), the constant C-string you are trying to assign consists of multiple bytes (characters). They are two different data types, and they are not compatible one and other.
5th Dec 2021, 3:26 AM
Ipang
+ 2
If you want to create a switch with character values, then you need to use enum. Example: enum EnumChar { A = 'a', B, C }; char c; cin >> c; switch(c){ case A: cout << A; break; case B: cout << B; break; case C: cout << C; break; default: cout << "??"; }
5th Dec 2021, 4:23 AM
Solo
Solo - avatar
+ 2
Oh I see ... so they are kinda obliged to use the transportation service cause that's where most of the expenses are, right? Fine, but still, what about that 5 out of 10 places, still don't get it. I think I should comment in your code when I have questions. I feel like I'm trashing this thread. Maybe I'll remove my comments here later ...
5th Dec 2021, 2:03 PM
Ipang
+ 2
Ipang I'm thinking what if we calculate first all the distance from each places and each rental fee, fuel cost for example User choose 1 for places then 1 for vehicle then calculate all the expenses then prompt the user again to choose 1 place then 1 vehicle the proceed until it has chosen 5 outputs and add all the total expenses would it be possible ?
6th Dec 2021, 10:55 AM
shlee_
shlee_ - avatar
+ 2
Can you show me the code that you revised?
6th Dec 2021, 1:36 PM
shlee_
shlee_ - avatar
+ 1
Thats my real name Vasiliy
5th Dec 2021, 3:14 AM
shlee_
shlee_ - avatar
+ 1
If you declare a variable as an array of characters, then you can assign it both one character and strings: char place[ ] = "Juliens Wreck"; place = "a"; char place[] is essentially identical to string place.
5th Dec 2021, 6:20 AM
Solo
Solo - avatar
+ 1
Are you seriously? You have a 1001 error in your code, but are you interested in the output of the last line? Be consistent. Write small but working code and gradually make changes to it.
5th Dec 2021, 7:19 AM
Solo
Solo - avatar
+ 1
Ipang yeah the code must ask them if how many day trips If they will not want to rent a car then they have no payment for rental and expenses if the user will not deposit for the rental fee then the code must not allow the user to rent a car return trip = 25 km* 2 = 50 km x day trips = total distance driver fee = day trip * 1500 Fuel cost = Fuel consumption * distance travelled * fuel cost per Liter fuel cost per Liter = 60 pesos this is the same for all vehicles total payment = DEPOSIT (10,000 ) - (Rental fee + driver fee + fuel cost)
5th Dec 2021, 9:02 AM
shlee_
shlee_ - avatar
+ 1
Ipang No they don't need to deposit if they want to use their own vehicle user need to deposit only if they want to rent a car
5th Dec 2021, 1:43 PM
shlee_
shlee_ - avatar
+ 1
Oki ,... The thing is the user must select only 5 places out of ten and 1 vehicle then calculate the expenses Ipang
5th Dec 2021, 1:46 PM
shlee_
shlee_ - avatar
+ 1
Now you make me confused. What do you mean 5 out of 10 places? I thought user was to choose one ... Which costs are included in the calculation when they want to use their own car? surely the fuel cost, driver rate are excluded ...
5th Dec 2021, 1:54 PM
Ipang
+ 1
That's why I make switch case and for loop at first if they want their own car there's no cost or payment Ipang
5th Dec 2021, 1:59 PM
shlee_
shlee_ - avatar
+ 1
The user can only select <= 5 specific place but not more than
5th Dec 2021, 2:02 PM
shlee_
shlee_ - avatar
+ 1
Ipang There are 10 diff places right in my code I write case with char for specific place a b c d e f g h I j So the user might input only 5 places to chose and not exceed on that example : places selected: a, b, j, h g it should not exceed to five
5th Dec 2021, 2:05 PM
shlee_
shlee_ - avatar