Reading a .txt file within a switch case My assignment requires me to create a noughts and crosses program.  I have managed to get all features working but I wish to add the ability to write to a text file, and call upon said file within a switch case (the switch case is used for the main menu).  Writing the file is not a problem however when it comes to reading it I get 'E0546 transfer of control bypasses initialization of:'.    I have tried containing the switch case {} which allows the program to run but the input is not recognised as being correct.  do    //Do at least once (do loop) - contains the 'game loop' {      mainMenu();      switch (menuChoice)     {     case 1:         cout &lt;&lt; "\t\t\t\t\t" &lt;&lt; "Please enter your name" &lt;&lt; endl;         cout &lt;&lt; "\t\t\t\t\t" &lt;&lt; "&gt;&gt;" &lt;&lt; endl;         cin &gt;&gt; playerNames[1];         init();                                                //Clear the grid and set to player one         do {             playerNames[2] = "Computer";             system("color 03");                                //Change text colour to blue             system("cls");                                     //Clear the screen             DisplayGrid();                                     //Display grid to screen             DisplayInput();                                    //Display input options relevant to single player             CheckInput();                                      //Check player input                                                 CheckStatus();                                     //Checks game status             easyAI();                                          //Computer turn that randomly fills a square             CheckStatus();             system("cls");          } while (toupper(input) != 'F' &amp;&amp; toupper(input) != 'M');                              //Checks the player hasn't quit or returned to menu        case 2:         cout &lt;&lt; "\t\t\t\t\t" &lt;&lt; "Player one please enter your name" &lt;&lt; endl;         cout &lt;&lt; "\t\t\t\t\t" &lt;&lt; " &gt;&gt;";         cin &gt;&gt; playerNames[1];         cout &lt;&lt; "\t\t\t\t\t" &lt;&lt; "Player two please enter your name" &lt;&lt; endl;         cout &lt;&lt; "\t\t\t\t\t" &lt;&lt; " &gt;&gt;";         cin &gt;&gt; playerNames[2];         init();                                                //Clear the grid and set to player one         do {             system("color 03");                                //Change text colour to blue             system("cls");                                     //Clear the screen             DisplayGrid();                                     //Display grid to screen             DisplayInput();                                    //Display input options relevant to multiplayer             CheckInput();                                      //Check player input             CheckStatus();                                     //Checks game status             system("cls");          } while (toupper(input) != 'F' &amp;&amp; toupper(input) != 'M');                              //Checks the player hasn't quit or returned to menu         break;       case 3:         howToplay();         break;      case 4:         runProg = false;         return 0;         break;      case 5:           ifstream reader("score.txt");                                if (!reader)         {             cout &lt;&lt; "Error opening file" &lt;&lt; endl;         }         default:         cout &lt;&lt; "Please use the correct input from the available choices" &lt;&lt; endl;         system("pause");     } } while (toupper(input) != 'F');  return 0;  system("pause");  }
Why can't variables be declared in a switch statement? I've always wondered this - why can't you declare variables after a case label in a switch statement?  In C++ you can declare variables pretty much anywhere (and declaring them close to first use is obviously a good thing) but the following still won't work:  switch (val)   {   case VAL:     // This won't work   int newVal = 42;     break; case ANOTHER_VAL:     ...   break; }     The above gives me the following error (MSC):     initialization of 'newVal' is skipped by 'case' label   This seems to be a limitation in other languages too.  Why is this such a problem?
I apologize if this question is posted on the wrong portion of the website, but I knew no better place to ask.  I've come to see that some effects, such as super-conduction may happen at either extremely low temperatures, or at extreme temperatures (the recent discovery of superconducting iron in the bowels of the earth, for one), and this is fascinating.  My question is: can (does?) the same principle be applied to quantum effects? Would it be applicable to, for example, say that although quantum effects happen at nano scales and below they may happen on a grand scale of say, the entire Universe (as a solitary unit)?  Can said quantum effects happen at moments of say, picoseconds after the Big Bang due to the turbulence of forces involves in such an event? Or even within the core of a dying star?  Thank you for any answers or clarification of my misinformation. Pretty much every application I use in full-screen (including Firefox, MacVim and the Terminal) have tabs on the top of the screen.  The problem is, when I move my mouse to reach the tabs I'll often accidentally touch the top of the screen, bringing in the OS menu OVER the tabs:    Is there any way to change this behavior? I'd prefer it if the menu bar would stay hidden when I'm using a full-screen app, even if my mouse does touch the top of the screen. Etymology of Tor and Ext Functors The names of the derived functors $\operatorname{Tor}$ and $\operatorname{Ext}$ seem quite cryptic to me. Does anyone know what these abbreviations stand for? I would be glad if someone could tell me where these names come from. Phase shift of 180 degrees of transversal wave on reflection from denser medium Can anyone please provide an intuitive explanation of why phase shift of 180 degrees occurs in the Electric Field of a EM wave, when reflected from an optically denser medium?  I tried searching for it but everywhere the result is just used.The reason behind it is never specified. I remember reading a sci-fi story where astronauts visit a planet, which is covered in stationary aliens with mile long necks that filter feed from the atmosphere.  It was published between 1960 and 2000.    It was in English and involved a pair of astronauts that went from planet to planet on a tour or something, though I don't know details of any other planets they visited. Can't access my home directory "Encrypted private directory is not setup properly" Hi I'm trying to access my home directory on my laptop hard drive through a live usb. I cannot boot into the OS on the hard drive and the home and root directory is encrypted. I have the encryption key but when I try to run the tool to gain access it pops up for a second then disappears and when I run the command in Terminal it says "Encrypted private directory is not setup properly". What are my options on getting into the directory? I really need to get the data off my laptop. LED light needs replacing every few weeks I have two GU5.3 bulbs in my bathroom - one of them went off a month or so ago so I bought the following 3 pack:   I've gone through 2 of the new bulbs in the space of weeks. I have never seen the bulbs fade out while being on, it's only when we turn the light switch on that they don't come back on (like this morning, I was first in the bathroom and the bulb was off again). No fuses blown or any indication of tripping.  How should I approach this? Where does gravitational waves' energy go? If refraction slows down light, isn't it possible to hold light still? I have a quick question about the refraction of light, and I'm sorry if it seems a bit simplistic or even stupid, but I'm still learning.  We know that when light passes through a denser medium, it slows down. However, is there a limit to that slowing down? If no, wouldn't it be possible, with some type of medium we make ourselves (like a crystal), to decrease the light's speed down to a point where we would be able to "see the photons moving forwards"?  I know it is way more complicated than that and that you can't see light unless some other light bounces off it, what I mean is slowing down light to an extreme and unusual speed). That sounds completely absurd but I can't seem to find what is wrong. Can anyone can explain it to me? :) When do I use "can" or "could"? When should I use can? When should I use could? What is right under what context? Boot drops to a (initramfs) prompts/busybox I am running an HP pavilion dv6000 dual boot win7 and Ubuntu 12.04. (well, up until today).  After a reboot, the boot process drops to the BusyBox shell and I end up at the prompt:  BusyBox v1.18.5 (Ubuntu 1:1.18.5-1ubuntu4) built-in shell (ash) Enter 'help' for a list of built-in commands.  (initramfs)   I've been researching others who have had this same problem, but haven't been able to find any of those solutions to work for me.  I tried the method described , and after the final command   mount -t ntfs-3g /dev/sda1 /root -o force   it does nothing and gives me another (initramfs) prompt.  I can boot to a live CD (USB) and get to a terminal, but it doesn't seem to do much good, as I can see the /dev/sda1 in the ls command, but it doesn't recognize it when I try to cd to it.  One more question: using the command fdisk -l how can I tell which mount point (sda1/sda2) is my windows partition and which one is Ubuntu? Can Superman see through his eyelids? How do I check to see if a text file is empty or does not exist in c++? Calculating p-values for two tail test for population variance A sporting goods manufacturer claims that the variance of string tensions for any decent tennis racquet should be about 9 pounds. The string tensions of 18 randomly selected tennis racquets produced a variance of 8.13 pounds. Find the p-value to test the manufacturer's claim (assume the population is normally distributed).  I tried attempting the question as follows: ${H_o}: {\sigma ^2} = 9$ ${H_1}: {\sigma ^2} \ne 9$ We are also given the following: $n=18$ $s^2 = 8.13$ Test Statistics: $\chi^2 = {{(n-1)S^2}\over{\sigma^2}}$ Calculating Test Statistics under $H_o$ gives us: $\chi^2 = {{(18-1)8.13}\over 9} = 15.35667$  For calculating the p-value I proceeded as follows: $p-value = 2\min\{P[\chi^2&gt;15.35667],\ P[\chi^2&lt;15.35667]\}\ =2\times 0.430192 = 0.860384$  I am not certain if my method for calculating the p-value is correct or not. Can someone please tell if the above process is valid?  Thanks in advance! Finding square root without using sqrt function? I'm trying to build a datapack that lets you craft xp bottles from glass bottles at the expense of 7 xp per bottle (because they drop 3 to 11 xp so the average is 7). I have almost everything working except for a check for if they have too little xp. If they have 7 or less xp, I would like to remove one bottle of enchanting from their inventory and give them one glass bottle, because the function for removing xp is called after they've crafted one and a scoreboard has counted it. My remove function currently looks like this:  #create dummy scoreboard to multiply bottles crafted by seven to get xp to be removed scoreboard objectives add 7xp dummy scoreboard players set @s 7xp -7 scoreboard players operation @s xpCrafted *= @s 7xp  #how do I get the value in xpCrafted into the command to remove xp? xp add @s -7 points  #cleanup scoreboard players reset xpCrafted scoreboard players reset 7xp scoreboard players set @e xpCrafted 0 scoreboard objectives remove 7xp   And my tick function like this:  execute as @e[scores={xpCrafted=1..}] at @s run function craft_xp:removexp   As the inline comment says, how do I get that value in xpCrafted into my xp removing command, and also how should I check to make sure the player has enough xp for the operation in the tick command (or elsewhere)? Presumably I would run a different command to remove the extra bottle if they didn't have enough xp, but I don't know how because there doesn't seem to be any type of if/else structure in commands. Finally, should a question like this be in two different questions or is one ok on this forum? What is the difference between $* and $@? How to include time factor in a mixed model (investigating the interaction between two factors and time)? How to install H.265 / HEVC codec on Ubuntu Linux? I have seen that the new  shows off H.265/HEVC playback, the successor of H.264. I wonder how I may get this support in Linux. Is there a need to install a codec specific for this format? How? No Dialect mapping for JDBC type: -9 with Hibernate 4 and SQL Server 2012