Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal error 'stdio.h' not found

Tags:

c

Why am I getting this message? The compiler is clang. Here is a simple program where it occurs for examples sake:

#include<stdio.h>

int fib(int);
int main()
{
    int i;
    scanf("%d",&i);
    printf("The fibonacci number that is %i'th in the sequence is %i \n", i, fib(i));
return 0;
}

int fib(int n)
{
    if (n==1 || n==0) return 1;
    else return fib(n-1)+fib(n-2);
}
like image 312
jones Avatar asked Dec 16 '22 14:12

jones


1 Answers

Assuming C

<stdio.h> is one of the standard C headers. Your compiler complains that it can not find this header. This means that your standard library is broken.

Consider reinstalling your compiler.

Assuming C++

<stdio.h> is the C standard header, with C++ we use <cstdio> instead. Though <stdio.h> is still required to exist in C++, so this probably isn't the problem.


Apart from these assumptions, it seems most likely (by your coding style and tags) that you are using C. Try this as some example code. This is guaranteed (by me) to compile on a working C compiler, if it doesn't then your compiler is horribly broken and you must install another one/reinstall:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {
    printf("Hello World!\n");
    return EXIT_SUCCESS;
}
like image 101
orlp Avatar answered Dec 25 '22 17:12

orlp