I'll give you a flag if you can get a negative number by adding only positive numbers.
nc rivit.dev 10009
int main(){ setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stdin, NULL, _IONBF, 0);
int acc = 0;
int n;
while (acc >= 0){
printf("acc = %d\n", acc);
printf("Enter a number: ");
if (scanf("%d", &n) != 1){
puts("Error reading integer");
} else {
if (n < 0){
puts("You can't enter the negative number!");
} else {
acc += n;
}
}
// デバッグ用: 強制的にaccを負の値に設定
if (acc >= 1000) {
acc = -1;
}
}
printf("You win! acc = %d\n", acc);
system("cat ./flag.txt");
}
Chat gpt helped me whit this
hint: integer overflow
1 month ago
hint: integer overflow