question

empleat-6716 avatar image
0 Votes"
empleat-6716 asked empleat-6716 answered

Visual studio Community - Source Not Available

Hope this is right forum to post. Microsoft forums are so chaotic...

I Am trying to execute simple C++ program in VS community 19 on Windows 10.

 #include <iostream>
    
 int main()
 {
     int j{ 0 };
     int x{ 0 };
        
     std::cout << "enter any number other than 5\n";
    
     do  {
         std::cin >> x;
         switch (j){
            
                
         case 0:
             std::cout << "enter any other number than 1\n";
             break;
         case 1:
             std::cout << "enter any other number than 2\n";
             break;
         case 3:
             std::cout << "enter any other number than 3\n";
             break;
         case 4:
             std::cout << "enter any other number than 4\n";
             break;
         case 5:
             std::cout << "enter any other number than 5\n";
             break;
         case 6:
             std::cout << "enter any other number than 6\n";
             break;
         case 7:
             std::cout << "enter any other number than 7\n";
             break;
         case 8:
             std::cout << "enter any other number than 8\n";
             break;
         case 9:
             std::cout << "enter any other number than 9\n";
             break;
         case 10:
             std::cout << "enter any other number than 10\n";
             break;
         }
            
            
         j++;
     } while (x != 5 && j < 10);
        
     if (x == 5) {
         std::cout << "you entered 5 you scoundrel";
     }
     else
         std::cout << "you are more patient than I Am!";
    
     return 0;
 }

Problem happens on runtime, when I enter number for a third time (case 3:), console hangs and nothing happens. I pressed ctrl+c and it threw some weird error and showed window, that sources are not available for module kernelbase.dll, or something. I tried to load sources, but it didn't help. Now same window isn't showing, but this shows after program execution.
84582-vs-studio-kernelbasedll-bug.png



PS: tell me how to rename post title, I don't know how would I even call this error!

Thanks for help.

vs-generalvs-debugging
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Viorel-1 avatar image
0 Votes"
Viorel-1 answered Viorel-1 edited

Add the missing ‘case 2: …’.

If you are less patient, you can also try something like this (without long switch):

 do 
 {
    std::cin >> x;
    std::cout << "enter any other number than " << ++j << std::endl;
 } while( x != 5 && j < 10 );


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Castorix31 avatar image
0 Votes"
Castorix31 answered

Your code has some bugs :

why switch (j) instead of switch (x) ?

there is no "case 2", so, as you test j, it does not display a message the 3rd time...

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

empleat-6716 avatar image
0 Votes"
empleat-6716 answered

LOL I Am blind xDD

I supposed something was wrong with Windows/VS. As it complained about some sources for module kernelbase.dll and opened some weird window about some symbols missing, or something. This is not a standard behavior, after debugging.

I repaired cases and now it works fine.

Thanks for help!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.