diff options
Diffstat (limited to 'decode.h')
-rw-r--r-- | decode.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/decode.h b/decode.h new file mode 100644 index 0000000..252fa4e --- /dev/null +++ b/decode.h @@ -0,0 +1,20 @@ +#ifndef DECODE_H +#define DECODE_H + +//stripNewlines: Takes a pointer to a null terminated string and the size of the string, removes the newlines and returns the new size. +int stripNewlines(char *string, int size) +{ +int a,s;//loop variables + for (a=0; a<size; ++a)//loop until the entirely of the string has been gone over + { + if (string[a] == '\n') + { + for (s=a;s<size;++s){string[s]=string[s+1];}//shift all characters above newline left 1, overwriting it + --size;//deincrement size since a character was removed + --a;//the next char may be a newline, so deincrement a to check it + } + } +return size; +} + +#endif |