Kindly assist me with making a single loop out of these four 'if' statement blocks. They're in the 'void room(room *room)' function. Here's the link to the code: http://txt.do/dbyw Thank you!
A simple change would be to go to if/ else if / else statement, but the switch statement is used for n-way branches.
I'm sorry, I don't understand. How does the if/else help with making it a single loop? Why did you mention the switch statement concept? n-way branching: number of switch statements involve? Do you have anything in particular I could read? Thanks.
My C is super rusty, but I think something like this should work: char *directions[4] = ["North \t", "South \t", "West \t", "East \t"]; for (i = 0; i < 4; i++) { if(room->neighbors[i] != NULL) { cout << directions[i]; } } or something to that extent...
Join our real-time social learning platform and learn together with your friends!