Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C problem

Name: Anonymous 2012-01-18 19:35

Is the behaviour of this program well defined?

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>

int main() {
    size_t num, min, max;
    if(scanf("%zu%zu%zu", &num, &min, &max) != 3) return 0;
    if(min >= num || max >= num || min > max) return 0;
    int *arr = calloc(num, sizeof(*arr));
    if(!arr) return 0;
    int *x = arr + min, *y = arr + max, *z = arr + (y - x);
    *x = 1, *y = 1, *z = 1;
    return 0;
}

Name: Anonymous 2012-01-19 22:32

>>11

Actually, sizeof can evaluate an expression, specially in C99 where VLAs may apply. This code >>16 shows how a sizeof will actually evaluate to argc.

This indeed is not the case in the original code, though.

>>14
>>15

Hello, ``faggot''. Talking to "mental midgets" and "toilet scrubblers" once more?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List