Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: unknown type name '#include' #include <stdio.h> [closed]

Tags:

c

terminal

macos

When I am using the terminal on the Mac to compile a .c file, I am getting following errors:

enter image description here

How can I handle these errors?

Here is the code:

#include <stdio.h>
int main()
{
  for (int i=1; i<=9; i++)
    {
      for (int j=1; j<=i; j++)
        {
          printf ("%d * %d = %2d ", j, i, j*i);
        }
      printf ("\n");
    }
}
like image 859
Rico Avatar asked Jul 28 '26 23:07

Rico


1 Answers

You've got an extra character/byte somewhere in there. Here's the text # include <stdio.h> annotated to show which character is at which offset:

# include <stdio.h>
^^^^^^^^^^^
12345678901

As you can see, < should be at offset 11, but the second line of your compiler output says it's at offset 12. That suggests that somewhere between the start of the file and the < you've got a stray byte that shouldn't be there.

I suggest deleting the line and manually retyping it. It's possible you just copied and pasted it but accidentally picked up some invalid characters/bytes while doing that.

like image 56
Cornstalks Avatar answered Jul 31 '26 11:07

Cornstalks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!