0

Everything was good, but after I added "case 2:" I got an error "Error: jump to case label [-fpermissive]. I don't have any idea what's wrong so I didn't even try to fix that. I'm making a word guess game, and for now it's not finished yet, because I wanted to eliminate the problem first. Here's the code:

#include <iostream>
#include <stdlib.h>
#include <cstdlib>
#include <time.h>
#include <windows.h>
#include <conio.h>
#include <string>
#include <fstream>
#include <algorithm>

using namespace std;

string slowo="pterodaktyl";
string kreski;
string kreska="_";
int zycia=6;
char wybor;
string strzal;
string strzalwyrazu;

int main()
{
   int dlugosc = slowo.size();

   for(int i=1; i<=dlugosc; i++)
   {
       kreski=kreski+kreska;
   }

while(slowo!=kreski)
{
   cout << "------MENU------" << endl;
   cout << "1. Zgadnij lietre" << endl;
   cout << "2. Zgadnij slowo" << endl;
   cout << "----------------" << endl;

   wybor=getch();

   switch(wybor)
   {
    case '1':
     cout << "Wybierz swoj strzal: ";
     cin >> strzal;
     cout << endl;

     size_t pozycja=slowo.find(strzal);
     cout << endl;

     if(pozycja!=string::npos)
     {
         kreski.replace(pozycja,1,strzal);
         cout << kreski;
         cout << endl << endl;
     }
     else
     {
        cout << "Nie trafiles! Tracisz jedno zycie" << endl;
        zycia--;
     }
     break;

    case '2': // Here's the error
         cin >> strzalwyrazu;
         if(strzalwyrazu==slowo)
            kreski.replace(0,dlugosc,strzalwyrazu);
     break;

        cout << "Pozostalych zyc: " << zycia << endl << endl;
   }
}

    return 0;
}

0 Answers0