mercredi 31 janvier 2018

c++ compiler configuration

#include <iostream>
#include <algorithm>
#include <string>

int main()
{
std::string s = "This is an example";
std::cout << s << '\n';

s.erase(0, 5); // Erase "This "
std::cout << s << '\n';

s.erase(std::find(s.begin(), s.end(), ' ')); // Erase ' '
std::cout << s << '\n';

s.erase(s.find(' ')); // Trim from ' ' to the end of the string
std::cout << s << '\n';
}

Output:

This is an example

is an example

isan example

isan

i run this code on code::blocks and it didn't get the same results as it is on cppreferences.com it's like the function find and erase does not have the same parametres or i don't know what is the problem my compiler version is cpp 5.1.0 if any one know how to fix this and get results as it is on the site, i'd greatfull if u tell me

Aucun commentaire:

Enregistrer un commentaire