
-----------------------------------
Shinobu
Tue Sep 03, 2013 8:22 pm

[C++ Help] Question about Switch-Case statement
-----------------------------------
So to use a switch-case statement, it's kinda like this:
switch (variable)
{
case "stuff":
	{
		//Code here
	}
case "more stuff here":
	{
		//More code here
	}
}
But can I insert code before the cases like this?
switch (variable)
{
	//Do stuff
case "stuff":
	{
		//Code here
	}
case "more stuff here":
	{
		//More code here
	}
}

It would be awesome if I can; I want to deallocate the pointer I'm using for the switch-case statement.

-----------------------------------
Dreadnought
Tue Sep 03, 2013 11:30 pm

Re: [C++ Help] Question about Switch-Case statement
-----------------------------------
You can probably place code there, but it will never execute since the switch will bring you to the appropriate case, avoiding the code.

I'm not sure what your doing that requires you to deallocate a pointer in the switch block but there is probably an alternative. Perhaps some more context would help?

-----------------------------------
Shinobu
Wed Sep 04, 2013 6:15 pm

Re: [C++ Help] Question about Switch-Case statement
-----------------------------------
You can probably place code there, but it will never execute since the switch will bring you to the appropriate case, avoiding the code.

I'm not sure what your doing that requires you to deallocate a pointer in the switch block but there is probably an alternative. Perhaps some more context would help?

Actually, nevermind about it.
I'm not going to try and save 1 byte of memory lol. Whatever XD
I was just trying to delete the variable that holds what the user inputs in my program, which is used in the switch-case.

-----------------------------------
Insectoid
Sat Sep 07, 2013 8:03 pm

RE:[C++ Help] Question about Switch-Case statement
-----------------------------------
You could just delete the variable right after the switch executes. If you're not allocating anything inside the switch, then it's not saving any RAM (and even then you're probably not saving anything).
