From 0e2c89d9393b0e207d4461fe709a17cfb8a7801c Mon Sep 17 00:00:00 2001 From: Ivaylo Ivanov Date: Sat, 15 Dec 2018 22:56:22 +0100 Subject: [PATCH] Revert to old line check --- cpair/cpair.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cpair/cpair.c b/cpair/cpair.c index 5670225..4a548f0 100644 --- a/cpair/cpair.c +++ b/cpair/cpair.c @@ -90,14 +90,14 @@ int main(int argc, char *argv[]) { node_t * current = head; while(fgets(input, __INT8_MAX__, stdin) != NULL) { ///< Read line by line - char *sep, *end; - float x = strtof(input, &sep); ///< if no characters were converted then input will point to end - float y = strtof(sep, &end); + /// Split the input by whitespace as delimiter + char *x = strtok(input, " "); + char *y = strtok(NULL, " "); - if(input != sep || sep != end) { + if(x != NULL && y != NULL) { /// Convert to float and save to the list - current -> points[0] = x; - current -> points[1] = y; + current -> points[0] = strtof(x, NULL); + current -> points[1] = strtof(y, NULL); current -> next = malloc(sizeof(node_t)); current = current -> next; point_num++; ///< Increase the list length