C - Off by one error, but no segmentation fault?
问题 I recently wrote this code in C: #include <stdio.h> #define N_ROWS 100 int main() { char *inputFileName = "triangle_data.txt"; FILE *inputFile = fopen(inputFileName, "r"); if (inputFile == NULL) { printf("ERROR: Failed to open \"%s\".\n", inputFileName); return -1; } int triangle[(N_ROWS*(N_ROWS+1))/2 - 1]; size_t size = sizeof(triangle)/sizeof(int); size_t index; for (index = 0; !feof(inputFile); ++index) { fscanf(inputFile, "%d", &triangle[index]); } return 1; } and was expecting a