home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
POINT Software Programming
/
PPROG1.ISO
/
c
/
actlib11
/
calc
/
simplify.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-14
|
536b
|
31 lines
/*
* Copyright (C) 1993 Marc Stern (internet: stern@mble.philips.be)
*
* SIMPLIFY
*
* Topic : Suppress trailing '0' of a string number
*
*/
#include "calc.h"
char *simplify( char *number )
{ char point = 0 ;
char *ptr1 , *ptr2 ;
for ( ptr1 = ptr2 = number ; *ptr1 ; ptr1 ++ )
{
if ( *ptr1 != '0' ) ptr2 = ptr1 ;
if ( *ptr1 == '.' ) point = 1 ;
}
if ( point ) *(ptr2 + 1) = '\0' ;
if ( *ptr2 == '.' ) *ptr2 = '\0' ;
return number ;
}