Reputation: 15
I'm using textpad on Windows 8, installed MinGW for compiling C
Not sure why this is causing trouble:
#include <stdio.h>
int main (void)
{
printf("To C, or not to C: that is the question.\n");
return 0;
}
The error says
C:\Users\Admin\Desktop\C files\pun.c:1:2: warning: null character(s) ignored [enabled by default]
#
^
C:\Users\Admin\Desktop\C files\pun.c:1:3: error: invalid preprocessing directive #i
#
^
cc1.exe: out of memory allocating 838860800 bytes
Tool completed with exit code 1
Upvotes: 0
Views: 491
Reputation: 881113
You've almost certainly saved your file with one of the Unicode encodings such as UTF-16
.
This assigns 16 bits to each character meaning that if you hes-dump your code, you'll see something like:
0000 - 23 00 69 00 6e 00 63 00 - 6c 00 75 00 64 00 5 00 - #.i.n.c.l.u.d.e.
at the start.
A compiler that doesn't understand UTF-16 will then probably complain bitterly about finding null bytes amongst all the real characters, just as yours seems to have done.
To fix it, either save the file in a more conventional form (such as ASCII) or find a compiler that can handle it. The former is probably the easier path to take provided you don't actually need all those non-ASCII Unicode characters.
Upvotes: 3