stdio.h : No such file or directory

I've just been following a getting started with C tutorial, the first task was to write a "Hello world!" program, the suggested code was:

#include < stdio.h>

void main()
{
  printf("\nHello World\n");
}

But when I came to compile it with gcc I got this error:

hello.c:1:21: error:  stdio.h : No such file or directory

I Googled and found plenty of forum posts, most suggested installing the build-essential package (I am running Ubuntu 10.4), however this was already installed and at the latest version, I also already had libc6-dev installed which was also suggested in a forum post I'd found.

Instinctively I decided to take an approach that had served me well in the past, it's called "mess with the code" :)

So, this is what worked for me:

#include <stdio.h>

void main()
{
  printf("\nHello World\n");
}

The difference? <stdio.h> instead of < stdio.h>

I suspect the error in the first code snippet is obvious but it caught me out and I hope this post saves someone some time!

Comments

Freaking awesome! I've been researching the same error for fairly annoying amount of time.

P.S Thankyou.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.