Revert to old line check

This commit is contained in:
Ivaylo Ivanov 2018-12-15 22:56:22 +01:00
parent a7b4aa82a5
commit 0e2c89d939

View File

@ -90,14 +90,14 @@ int main(int argc, char *argv[]) {
node_t * current = head; node_t * current = head;
while(fgets(input, __INT8_MAX__, stdin) != NULL) { ///< Read line by line while(fgets(input, __INT8_MAX__, stdin) != NULL) { ///< Read line by line
char *sep, *end; /// Split the input by whitespace as delimiter
float x = strtof(input, &sep); ///< if no characters were converted then input will point to end char *x = strtok(input, " ");
float y = strtof(sep, &end); char *y = strtok(NULL, " ");
if(input != sep || sep != end) { if(x != NULL && y != NULL) {
/// Convert to float and save to the list /// Convert to float and save to the list
current -> points[0] = x; current -> points[0] = strtof(x, NULL);
current -> points[1] = y; current -> points[1] = strtof(y, NULL);
current -> next = malloc(sizeof(node_t)); current -> next = malloc(sizeof(node_t));
current = current -> next; current = current -> next;
point_num++; ///< Increase the list length point_num++; ///< Increase the list length