I am working on replit and is giving me this error message:
clang++-7 -pthread -std=c++17 -o main main.cpp
main.cpp:25:3: error: unknown type name 'cout'
cout << "Good day adventurer! Are you ready to plan y...
^
main.cpp:25:8: error: expected unqualified-id
cout << "Good day adventurer! Are you ready to plan y...
^
main.cpp:27:3: error: expected unqualified-id
while(valid){
^
3 errors generated.
compiler exit status 1
Here is the code...
#include <iostream>
#include <vector>
using namespace std;
void startup();
bool run = true;
vector<string> list;
int main() {
while(run)
startup();
cout << "Have a good day young adventurer!\n";
}
void startup();
bool valid = true;
int num, remNum;
cout << "Good day adventurer! Are you ready to plan your quest?\n1) Add an Event\n2) Remove an Event\n3) View your schedule\n4) Leave and Depart on your journey!\n";
while(valid){
cin >> num;
cin.ignore();
switch(num){
case 1:
cout << "What shall be on your quest, and at what time?\n";
getline(cin, events);
list.push_back(events);
break;
case 2:
if(list.empty())
cout << "There is nothing on your quest yet.\n";
else{
cout << "Which part of the quest shall I terminate?\n";
cin >> remNum;
list.erase(list.begin() + (remNum - 1));
}
break;
case 3:
if(list.empty())
cout << "There is nothing on your quest yet.\n";
else{
for (int i = 0; i < list.size(); i++)
cout << i + i << ")" << list[i] << endl;
}
break;
case 4:
run = false;
valid = false;
break;
default:
cout << "Sorry adventurer, that is beyond my powers.\n"
break;
}
if(valid)
cout << "\n Is there anything else you wish to do adventurer?\n"
}
It depends on what function you want the code to be part of.
My suspicion is that you tried to put it inside the startup() function but then you need to change
1 2 3 4 5
void startup();
bool valid = true;
int num, remNum;
cout << "Good d
...
to
1 2 3 4 5 6
void startup() {
bool valid = true;
int num, remNum;
cout << "Good d
...
}