summaryrefslogtreecommitdiff
path: root/battfmt.c
diff options
context:
space:
mode:
Diffstat (limited to 'battfmt.c')
-rw-r--r--battfmt.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/battfmt.c b/battfmt.c
new file mode 100644
index 0000000..14e0832
--- /dev/null
+++ b/battfmt.c
@@ -0,0 +1,28 @@
+#include <u.h>
+#include <libc.h>
+#include <ctype.h>
+
+void
+battfmt(char *buf, long buflen)
+{
+ char *s;
+
+ for(s = buf; (s-buf) < buflen; s++)
+ if(!isdigit(*s)){
+ for(;(s-buf) < buflen; s++)
+ *s = '\0';
+ break;
+ }
+}
+
+void
+main(void)
+{
+ char str[] = "30 m";
+
+ battfmt(str, 4);
+
+ print("%s\n", str);
+
+ exits("done");
+}