#include <iostream>
int main() {
int i;
scanf("%d", &i);
printf("%d\n", i);
return 0;
}
This is a simplified version of code that I stumbled upon in a blog about problem solving in c++. I noticed something strange as I thought scanf() and printf() are used with stdio.h.
https://en.cppreference.com/w/cpp/header/iostream: this site shows that scanf() and printf() is not included in iostream. But when I copied and pasted the code on Visual Studio Code and compiled it with gcc on my mac terminal, it compiled fine and ran fine. So I am confused as whether scanf() and printf() can also be used just with iostream.