diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json deleted file mode 100644 index dfe7034..0000000 --- a/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "configurations": [ - { - "name": "Win32", - "includePath": [ - "${workspaceFolder}/**" - ], - "defines": [ - "_DEBUG", - "UNICODE", - "_UNICODE" - ], - "compilerPath": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\gcc.exe", - "cppStandard": "gnu++14", - "intelliSenseMode": "windows-gcc-x64" - }, - { - "name": "Linux", - "includePath": [ - "${workspaceFolder}/**" - ], - "defines": [ - "_DEBUG", - "UNICODE", - "_UNICODE" - ], - "compilerPath": "/usr/bin/gcc", - "cppStandard": "gnu++14", - "intelliSenseMode": "linux-gcc-x64", - "cStandard": "c17" - } - ], - "version": 4 -} diff --git a/voronoi.c b/voronoi.c index ff16e13..12daee2 100644 --- a/voronoi.c +++ b/voronoi.c @@ -24,21 +24,7 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } - char *buffer; - size_t bufsize = 32; - size_t characters; - - buffer = (char *)malloc(bufsize * sizeof(char)); - if( buffer == NULL) - { - perror("Unable to allocate buffer"); - exit(1); - } - - printf("Type something: "); - characters = getline(&buffer,&bufsize,stdin); - printf("%zu characters were read.\n",characters); - printf("You typed: '%s'\n",buffer); + readWatchtowers(watchtowers, dataset); // Cleaning up data free(watchtowers); @@ -75,6 +61,24 @@ FILE **polygonFile, FILE **outputFile) { } void readWatchtowers(watchtower_t *watchtowers, FILE* datasetFile) { - int numTowers = 1; - + char *lineBuffer; + int lineCount = 0; + size_t lineBufferSize = 512; + size_t numberCharsRead; + + lineBuffer = (char *) malloc(lineBufferSize * sizeof(char)); + if (lineBuffer == NULL) { + fprintf(stderr, MALLOC_ERROR); + exit(EXIT_FAILURE); + } + + numberCharsRead = getline(&lineBuffer, &lineBufferSize, datasetFile); + while (numberCharsRead > 0) { + lineCount += 1; + printf("line[%06d]: chars=%06zd, buf size=%06zu, contents: %s",\ + lineCount, numberCharsRead, lineBufferSize, lineBuffer); + numberCharsRead = getline(&lineBuffer, &lineBufferSize, datasetFile); + } + free(lineBuffer); + lineBuffer = NULL; } diff --git a/voronoi1 b/voronoi1 old mode 100644 new mode 100755 index a1ce316..0e46e25 Binary files a/voronoi1 and b/voronoi1 differ