how to check and remove leading zeroes from the buffer using c program
Helo ,
I m writing small module of c.on RHEL 4 I have one buffer (for e.g. buffer = "002" now I want to check whethere buffer contains leading zeroes and if it contains leading zeroes then I want to remove all leading zeroes ( i.e. if buffer = "002" then I want to make buffer = "2") how do I do using c code Regards, Amit |
Easy way? Try using strtol() and sprintf(), something like this
Code:
int value; You can also use the atoi() function (the strtol() function is more complicated): Code:
#include <stdio.h> |
Another option, is to use strtok().
PHP Code:
|
Quote:
|
or something really simple
Code:
char buf [BUFSIZ]; |
All times are GMT -5. The time now is 04:09 PM. |