summaryrefslogtreecommitdiffstats
path: root/decode.h
blob: 252fa4e74df644ed54697570b1db2d134201506f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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