Playground error | Sololearn: Learn to code for FREE!

+1

Playground error

I just can't figure out why the playground doesn't run this simple code: #include <iostream> using name space std; int main() { int *p = new int; *p = 5; cout <<*p<< endl; delete p; return 0; } \\ get the following errors: "..\Playground\:2:7: error: expected nested-name-specifier before 'name' using name space std; ^~~~ ..\Playground\: In function 'int main()': ..\Playground\:8:5: error: 'cout' was not declared in this scope cout <<*p<< endl; ^~~~ ..\Playground\:8:5: note: suggested alternative: In file included from ..\Playground\:1:0: ..\Playground\-w64..\Playground\-w64-mingw32..\Playground\++/iostream:61:18: note: 'std::cout' extern ostream cout; /// Linked to standard output ^~~~ ..\Playground\:8:17: error: 'endl' was not declared in this scope cout <<*p<< endl; ^~~~ ..\Playground\:8:17: note: suggested alternative: In file included from ..\Playground\-w64..\Playground\-w64-mingw32..\Playground\++/iostream:39:0, from ..\Playground\:1: ..\Playground\-w64..\Playground\-w64-mingw32..\Playground\++/ostream:590:5: note: 'std::endl' endl(basic_ostream<_CharT, _Traits>& __os) ^~~~"

12/10/2018 5:12:40 PM

Cristian Dimitrov

1 Answer

New Answer

+8

namespace should be a single word