Mr Habib
Mr Habib

Reputation: 1

XCode compile: "undeclare use of cin" how do i fix it?

I've been using Xcode 10.0 on my mac and whenever I use cin, the compiler shows an error:

|6|error: use of undeclared identifier cin|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

However, cout and other c++ built-ins are working just fine...

A few days ago I have commented out some header file in gcc's header file folder for another bug. (Is there any chance to create this problem for what I've done before with the header file folder?)

Upvotes: 0

Views: 201

Answers (1)

Jesper Juhl
Jesper Juhl

Reputation: 31447

You need to

#include <iostream>

to be able to use std::cin. If you want to avoid the std:: namespace prefix, add

using std::cin;

to your code as well.

Upvotes: 1

Related Questions