From be7ec2c186c1c418c40b3b70e339fbd77c0ad1ff Mon Sep 17 00:00:00 2001 From: kr820js Date: Sat, 23 Mar 2024 19:56:38 +0100 Subject: [PATCH] submition9 --- a1/program.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/a1/program.c b/a1/program.c index e59b2d7..38ea520 100644 --- a/a1/program.c +++ b/a1/program.c @@ -76,7 +76,7 @@ int analizing_string(char* pointer){ int i = 0; int counter=0; while(pointer[i]!='\0'){ - if(pointer[i]=='+'||pointer[i]=='/'||pointer[i]=='*'||pointer[i]=='-'){ + if(pointer[i]=='+'||pointer[i]=='/'||pointer[i]=='*'){ operant=pointer[i]; counter++; if(counter>1){ @@ -158,14 +158,16 @@ int skip_spaces(int i, char *pointer) { int copy_number(char number[], char *pointer, int i) { int destination_i = 0; while(pointer[i]!='\0'){ - if (!isdigit(pointer[i])&&pointer[i]!='.'&&pointer[i]!=',') { + if (!isdigit(pointer[i])&&pointer[i]!='.'&&pointer[i]!=','&&pointer[i]!='-') { + break; + } + if (pointer[i] == '-' && destination_i > 0) { break; } number[destination_i] = pointer[i]; destination_i++; i++; } - return i; }