Visual studio Community - Source Not Available

empleat 126 Reputation points
2021-04-05T19:45:08.023+00:00

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.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,565 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
932 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 111.6K Reputation points
    2021-04-05T20:03:09.75+00:00

    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 );
    
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Castorix31 81,361 Reputation points
    2021-04-05T20:13:19.173+00:00

    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...

    0 comments No comments

  2. empleat 126 Reputation points
    2021-04-05T20:38:08.203+00:00

    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!

    0 comments No comments