I’m stuck on Stage #(the type built-in).
I’ve copied the code and run it on another prj myself and it did work
Here are my logs:
include relevant logs here (please make sure to keep the backticks around this!)
```remote: [compile] -- Running vcpkg install
remote: [compile] All requested packages are currently installed.
remote: [compile] Total install time: 79.6 us
remote: [compile] -- Running vcpkg install - done
remote: [compile] -- The C compiler identification is GNU 13.2.0
remote: [compile] -- The CXX compiler identification is GNU 13.2.0
remote: [compile] -- Detecting C compiler ABI info
remote: [compile] -- Detecting C compiler ABI info - done
remote: [compile] -- Check for working C compiler: /usr/bin/cc - skipped
remote: [compile] -- Detecting C compile features
remote: [compile] -- Detecting C compile features - done
remote: [compile] -- Detecting CXX compiler ABI info
remote: [compile] -- Detecting CXX compiler ABI info - done
remote: [compile] -- Check for working CXX compiler: /usr/local/bin/c++ - skipped
remote: [compile] -- Detecting CXX compile features
remote: [compile] -- Detecting CXX compile features - done
remote: [compile] -- Configuring done (0.7s)
remote: [compile] -- Generating done (0.0s)
remote: [compile] -- Build files have been written to: /app/build
remote: [compile] [ 50%] Building CXX object CMakeFiles/shell.dir/src/main.cpp.o
remote: [compile] /app/src/main.cpp: In function 'int main()':
remote: [compile] /app/src/main.cpp:24:33: error: no matching function for call to 'find(std::vector<std::__cxx11::basic_string<char> >::iterator, std::vector<std::__cxx11::basic_string<char> >::iterator, std::__cxx11::basic_string<char>)'
remote: [compile] 24 | if (find(built_in_types.begin(), built_in_types.end(), input.substr(5)) != built_in_types.end()) {
remote: [compile] | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
remote: [compile] In file included from /usr/local/include/c++/13.2.0/bits/locale_facets.h:48,
remote: [compile] from /usr/local/include/c++/13.2.0/bits/basic_ios.h:37,
remote: [compile] from /usr/local/include/c++/13.2.0/ios:46,
remote: [compile] from /usr/local/include/c++/13.2.0/ostream:40,
remote: [compile] from /usr/local/include/c++/13.2.0/iostream:41,
remote: [compile] from /app/src/main.cpp:1:
remote: [compile] /usr/local/include/c++/13.2.0/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
remote: [compile] 435 | find(istreambuf_iterator<_CharT> __first,
remote: [compile] | ^~~~
remote: [compile] /usr/local/include/c++/13.2.0/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
remote: [compile] /app/src/main.cpp:24:33: note: '__gnu_cxx::__normal_iterator<std::__cxx11::basic_string<char>*, std::vector<std::__cxx11::basic_string<char> > >' is not derived from 'std::istreambuf_iterator<_CharT>'
remote: [compile] 24 | if (find(built_in_types.begin(), built_in_types.end(), input.substr(5)) != built_in_types.end()) {
remote: [compile] | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
remote: [compile] gmake[2]: *** [CMakeFiles/shell.dir/build.make:76: CMakeFiles/shell.dir/src/main.cpp.o] Error 1
remote: [compile] gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/shell.dir/all] Error 2
remote: [compile] gmake: *** [Makefile:91: all] Error 2
remote: [compile] Looks like your code failed to compile.
remote: [compile] If you think this is a CodeCrafters error, please let us know at hello@codecrafters.io.
remote:
And here's a snippet of my code:
```c++
include relevant code here (please make sure to keep the backticks around this!)
```#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
// Flush after every std::cout / std:cerr
cout << std::unitbuf;
cerr << std::unitbuf;
vector <std::string> built_in_types = { "echo","exit","type" };
// Uncomment this block to pass the first stage
while (true)
{
cout << "$ ";
string input;
getline(std::cin, input);
if (input == "exit 0") return 0;
else if (input.find("type") != -1)
{
if (find(built_in_types.begin(), built_in_types.end(), input.substr(5)) != built_in_types.end()) {
cout << input.substr(5) << " is a shell builtin" << endl;
}
}
else if (input.find("echo") != -1) {
cout << input.substr(5) << "\n";
}
else {
cout << input << ": command not found" << endl;
}
}
}