2

I am trying to enter the simple "Hello World!" code, but cout and endl are undefined.

#include<iostream>
#include "stdafx.h"
int main()
{
    std::cout << "Hello World!" << std::endl;
}

It turns out the errors: "'cout': is not a member of 'std', note: see declaration of 'std', 'cout': undeclared identifier", and the same with endl. Please Help.

Fruchtzwerg
  • 10,999
  • 12
  • 40
  • 49

1 Answers1

1

You are missing a space in the #include statement: #include<iostream>

This is the correct way: #include <iostream>

Full code:

#include <iostream>
#include "stdafx.h"
int main()
{
    std::cout << "Hello World!" << std::endl;
}
Daniel Illescas
  • 5,346
  • 3
  • 17
  • 23