For example if input "-1" then output -1
if input "+1" then output 1
if input "1,01" then output 1,01
now my Task is to write a condition to get an output 1 if the input for example "1,000" so I have to clean all zeros after the comma and clean the comma too. Hope You can help and thnx in advance.
here is my function :
char *str_dup(const char * const str)
{
unsigned long length = 0;
for(int i = 0; str[i] != '\0'; i++)
length++;
char *new_str = malloc(sizeof(char) * (length + 1));
for(int i = 0; str[i] != '\0'; i++){
if (str[0]=='+')
{
new_str[i] = str[i+1];
}
else
{
new_str[i] = str[i];
}
}
new_str[length] = '\0';
return new_str;
}