Why isn't indexing a 2D Array by pointer arithmetic the same as using [j] brackets, though the spec says it should be?

Advertisements Learning C, I stumbled upon this video on which page 82 of the C99 specification appears (though it’s dated 2007, maybe a revision?). Therein it is stated that any expression that indexes arrays using subscripts, such as E1[E2], where one is pointer to object type and the other is type integer, is identical to… Read More Why isn't indexing a 2D Array by pointer arithmetic the same as using [j] brackets, though the spec says it should be?

Ambiguous behavior by GCC when it ought to decide scope for a function declaration

Advertisements By reading the C99 standard specification draft (n1256) section 6.7.5.3 paragraph 17, from what I can take away the function declarations (including implicit) inside a block scope shall have a block scope. Simple and makes sense. However it doesn’t make any sense, because when I compile this code: void func1 () { int f(int);… Read More Ambiguous behavior by GCC when it ought to decide scope for a function declaration

How do I write a string into a file in C without writing (null)?

Advertisements This is what I have got: #include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> int main(int argc, char* argv[]) { unsigned short index; srand(time(NULL)); index = rand(); char * task = ""; unsigned short i=0; for (; i < strlen(task); i+=task[i]) ; index = (index + i) % 999; FILE * file = fopen("file.txt",… Read More How do I write a string into a file in C without writing (null)?