Can someone explain? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can someone explain?

In my code I'll try to have a string variable into switch. Because this is imposible I made a pointer like this so I can put it as integer. int *pntr_hypo pntr_hypo = &hypo and then compiler shows me an error: error: expected initializer before 'pntr_hypo' I tried to initialise it but I'm not sure what I should do. Can you help me?

22nd Apr 2017, 10:13 PM
Γιάννης Δημητριάδης
Γιάννης Δημητριάδης - avatar
5 Answers
+ 2
variable hypo must be defined. every line finish with semicolon int hypo; int* pntr_hypo; pntr_hypo = &hypo; I publish this code in the Code Playground as "pointer c plus plus"
22nd Apr 2017, 10:29 PM
⏩▶Clau◀⏪
⏩▶Clau◀⏪ - avatar
0
hypo is string
22nd Apr 2017, 10:44 PM
Γιάννης Δημητριάδης
Γιάννης Δημητριάδης - avatar
0
since hypo is a string, use: string hypo; string *hypo_ptr; hypo_ptr = &hypo;
23rd Apr 2017, 2:41 AM
Bill Fosam
Bill Fosam - avatar
0
The problem is into switch. It doesn't accept it.
23rd Apr 2017, 9:03 AM
Γιάννης Δημητριάδης
Γιάννης Δημητριάδης - avatar
0
As I know you can't put string variable in switch
23rd Apr 2017, 9:04 AM
Γιάννης Δημητριάδης
Γιάννης Δημητριάδης - avatar