Playground error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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) ^~~~"

10th Dec 2018, 5:12 PM
Cristian Dimitrov
Cristian Dimitrov - avatar
1 Answer
+ 8
namespace should be a single word
10th Dec 2018, 5:19 PM
Moses Odhiambo
Moses Odhiambo - avatar