diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml new file mode 100644 index 0000000..69c1ae2 --- /dev/null +++ b/.github/workflows/compile.yml @@ -0,0 +1,18 @@ +name: compile + +on: + push: + branches: "**" + pull_request: + branches: [ main ] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Compile main.cpp + run: g++ -std=c++17 main.cpp -o main \ No newline at end of file diff --git a/main.cpp b/main.cpp index 982d05f..83236b2 100644 --- a/main.cpp +++ b/main.cpp @@ -19,11 +19,19 @@ int main(){ pick = rand() % 4; cout << "What are you listening to?\n"; getline(cin,input); + + if (input.empty()) { // exit if nothing entered + return 0; +} cout << VALIDATION[pick] << "! Let's listen to more\n"; do{ cout << "What's next?\n"; getline(cin,input); + + if (input.empty() || input == "nothing") { // exit if nothing or is user types "nothing" + return 0; +} pick = rand() % 4; cout << VALIDATION[pick] << "!\n"; }while( input != "nothing" );