Skip to content

Commit

Permalink
Deltadebugging fix check loop boundaries
Browse files Browse the repository at this point in the history
  • Loading branch information
Perun CaseStudies authored and Perun CaseStudies committed Nov 11, 2024
1 parent f07bdc8 commit 72f74da
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions tests/sources/delta_debugging_examples/dd-minimal/main.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>

#define MAGIC_NUMBER 100
#define BUFFER_SIZE 256

void magicLoop() {
for (int i = 0; i < MAGIC_NUMBER; ++i) {
Expand All @@ -28,13 +30,22 @@ int main(int argc, char* argv[]) {
if (argc != 2) {
return 1;
}

FILE * fp = fopen(argv[1],"r");
char fileContent[15];
int i = 0;
char ch;
while ((i < sizeof(fileContent) - 1) && (ch = fgetc(fp)) != EOF) {
fileContent[i++] = ch;

if (fp == NULL) {
printf("Error opening file\n");
return 1;
}

char fileContent[BUFFER_SIZE];

while (fscanf(fp, "%255s", fileContent) == 1) {

printf("read line: %s\n", fileContent);
}

fclose(fp);
checkInputString(fileContent);
return 0;
}

0 comments on commit 72f74da

Please sign in to comment.