-3

the code i wrote

What am i doing wrong in here it gives me an error and its very very basic.

enter code here

# include <iostream>
using namespace std;
int main()
{
    string firstone = "giraffe academy";
    cout << firstone.substr(8, 3);

    return 0;
}
Bill Hileman
  • 2,798
  • 2
  • 17
  • 24
elf
  • 1
  • 2

1 Answers1

2

You need to

# include <string>

that defines << for std::string

Vlad Feinstein
  • 10,960
  • 1
  • 12
  • 27
  • in the video, I watched guy did it without using include part. Can that be because of the compilers we use? – elf Mar 03 '21 at 05:44
  • @elf not so much a compiler as the `std` library; see the link posted in the comments for details. – Vlad Feinstein Mar 03 '21 at 17:02