Last active
December 10, 2015 00:58
-
-
Save james4k/4354920 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdio.h" | |
#include "string.h" | |
void InsertHtmlSpace(char *inout, unsigned int len) | |
{ | |
unsigned int spaces = 0; | |
unsigned int i, o; | |
for (i = 0; i < len; i++) | |
{ | |
if (inout[i] != ' ') | |
continue; | |
spaces++; | |
} | |
inout[len + spaces * 2] = 0; | |
for (i = len - 1; i >= 0; i--) | |
{ | |
if (inout[i] != ' ') | |
{ | |
inout[i + spaces * 2] = inout[i]; | |
} | |
else | |
{ | |
spaces--; | |
o = i + spaces * 2; | |
inout[o] = '%'; | |
inout[o+1] = '2'; | |
inout[o+2] = '0'; | |
if (spaces == 0) | |
return; | |
} | |
} | |
} | |
int main(int argc, char *argv[]) | |
{ | |
char blerg[255]; | |
char *sarr[] = | |
{ | |
"This is a test strrrring.", | |
"Produce debugging information in the operating system's native format (stabs, COFF, XCOFF, or DWARF 2). GDB can work with this debugging information", | |
"gistfile1.c C 679 bytes", | |
NULL | |
}; | |
char *s; | |
int i = 0; | |
for (s = sarr[i]; s != NULL; s = sarr[++i]) | |
{ | |
strcpy(blerg, s); | |
InsertHtmlSpace(blerg, strlen(blerg)); | |
printf("%s\n\n%s\n---\n", s, blerg); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment