0

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?)

sepp2k
  • 363,768
  • 54
  • 674
  • 675
  • Please provide a [repro] demonstrating the error. – walnut Apr 11 '20 at 15:16
  • 4
    Also: "*few days ago i have comment out some header file on gcc compiler's header file folder*": What does that mean? Did you modify the header files distributed with the compiler? Never ever do that. If you did, remove and install the compiler again. – walnut Apr 11 '20 at 15:18

1 Answers1

1

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.

Jesper Juhl
  • 30,449
  • 3
  • 47
  • 70
  • #include using namespace std; int main() { int n; cin>>n; cout< – Mr Habib Apr 12 '20 at 03:18
  • @MrHabib Don't *ever* `#include`. See [Why should I not #include ?](https://stackoverflow.com/q/31816095/5910058). And `using namespace stdc;` is also rather bad practice - *especially* after that other header drags in everything and the kitchen sink. – Jesper Juhl Apr 12 '20 at 06:37