0

I have an error with #include <bits/stdc++h.> puts "No such file or directory"

#include <bits/stdc++h.>
using namespace std; 

int main(){

    int numero = 0, divisor = 0, cociente = 0, residuo = 0;

    cout<<"Introduce un numero entero a dividir; ";
    cin>>numero;
    cout<<"Introduce un divisor entero: ";
    cin>>divisor;

    cociente = numero/divisor;
    residuo  = numero%divisor;

    cout<<"El cociente de la division "<<numero<<" / "<<divisor<<" = "<<cociente<<;
    cout<<"El residuo de la division "<<numero<<" / "<<divisor<<" = "<<residuo<<;


    return 0;

}
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Dilan Beltrán
  • 1
  • 1
  • 1
  • 1

1 Answers1

2

You misspelled the header: #include <bits/stdc++h.> when it should be #include <bits/stdc++.h>

Also its not a standard header, its a GCC header. So it will only work with that compiler and not for example, Visual Studio.

Youre better off using the standard headers instead of relying on bits/stdc++ to include them all. Because it can eventually drop some and suddenly your code wont work, and since it includes all these headers, your compile times will be a lot slower.

In your case, the header you need is #include <iostream>

pacukluka
  • 728
  • 4
  • 18
  • 1
    For the OPs code, the correct header is `#include ` – PaulMcKenzie May 13 '20 at 01:38
  • bits/stdc++ includes it – pacukluka May 13 '20 at 01:40
  • 2
    Yes, and that's the problem. Read the comment in the main section as to why that header shouldn't be used. – PaulMcKenzie May 13 '20 at 01:41
  • I have. It still has its uses. Eg coding competitions. – pacukluka May 13 '20 at 01:41
  • And what uses do these "coding competitions" have? – Sam Varshavchik May 13 '20 at 01:44
  • There is a time limit. Its more important to remember the algorithms and concepts than worry about including all the headers. – pacukluka May 13 '20 at 01:45
  • Especially if the time limit is short or if there are multiple problems. Also allows for better rapid prototyping. – pacukluka May 13 '20 at 01:46
  • @LukaKostic -- For the OP's code, only one standard header needs to be included. Plus StackOverflow is not a competition. There is no time clock when a question is posted. Why do so many think there is a clock on StackOverflow? Wouldn't the time spent posting a question on SO be well spent figuring out what the headers to use are? – PaulMcKenzie May 13 '20 at 01:47
  • Never said there is. His question was why his include wasnt working. Why is your answer 'dont even use that header' when it has valid uses and reasons for existing. Its widely used in competitions and his question was about using it. – pacukluka May 13 '20 at 01:48
  • If you read the question, you really don't know why that error is given -- you guessed. What if the OP is using Visual Studio, where that header doesn't exist? – PaulMcKenzie May 13 '20 at 01:49
  • In that case, i will adjust the answer. In any way, there is a typo in the title, and probably code too. – pacukluka May 13 '20 at 01:50
  • Idk man seems like a great quality to have if you need to work under pressure of deadlines. Also knowledge of algorithms and data structures. As well as computation time limitations on some, forcing you to optimize and think about different ways of solving the problem. Quite good qualities to have for a programmer. – pacukluka May 13 '20 at 02:12