Open daxida opened 3 months ago
CG has a useful way to give feedback upon printing uninitialized (is it?) memory, but locally there is no way of knowing, and the STDOUT message seems to contain no mistakes (since the the characters are not printed / are zero width).
Link of the contribution where this was tested.
C code used:
#include <stdio.h> int main() { int N; scanf("%d", &N); for (int i = 0; i < N; i++) { char num[15 + 1]; scanf(" %[^\n]", num); int ptr = 0; int minus = 0; while (ptr < 15 && num[ptr] == '0' || num[ptr] == '+' || num[ptr] == '-') { if (num[ptr] == '-') { minus += 1; } ptr++; } if (minus % 2) printf("-"); for (int i = ptr; i < 15; i++) { // This ends up printing uninitialized memory ??? printf("%c", num[i]); // fprintf(stderr, "%d\n", num[i]); } printf("\n"); } return 0; }
CG has a useful way to give feedback upon printing uninitialized (is it?) memory, but locally there is no way of knowing, and the STDOUT message seems to contain no mistakes (since the the characters are not printed / are zero width).
Link of the contribution where this was tested.
C code used: