c++ - How do I fix these "Undefined Reference" errors in Ubuntu? -
g++ 4.7.
to fix debug error, added -std=c++11 build command. i'm getting ton of "undefined reference" errors one:
'in function encrypt(std::string&, int)': /home/bob/workspace/new/debug /../test.cpp:10: undefined reference std::string::begin()' /home/bob/workspace/new/debug/../test.cpp:10: undefined reference std::string::end()' ./test.o: in function main': /home/bob/workspace/new/debug/../test.cpp:24: undefined reference `std::basic_string, std::allocator >::basic_string()'" '
what need fix ? here's code
#include <iostream> #include <string> using namespace std; void encrypt(std::string &iostr, int key) { key %= 26; int ch; (auto &it : iostr) { ch = tolower(it); if (!islower(ch)) { continue; } ch += key; if (ch > 'z') { ch -= 26; } = ch; } } int main() { string source; int key = 1; cout << "paste cyphertext , press enter shift each letter right 1"; getline(cin, source); encrypt(source, key); cout << source << ""; encrypt(source, key); cout << source << endl; cout << "press enter exit"; cin.ignore(cin.rdbuf()->in_avail() + 1); return 0; }
Comments
Post a Comment