L
lolzy
Good day!
When I use this function, I get the following output:
runtime error R6002
- floating point support not loaded
Note:
- safeMalloc() is a safe function with error handling.
- sizeof(string) >= sizeof(buf) (so no overflows)
/*
* Encode a string according to http://tools.ietf.org/html/rfc3986#section-2.1.
*/
void urlEncode(char *string)
{
int i = 0;
char *buf = safeMalloc(((strlen(string) * 3) + 1) * sizeof(char));
buf[0] = '\0';
while (string != '\0')
{
if (isalnum(string) || string == '-' || string == '_' ||
string == '.' || string == '~' || string == ' ')
{
if (string == ' ') string = '+';
sprintf(buf, "%s%c", buf, string);
}
else
{
sprintf(buf, "%s%%%.2X", buf, string);
}
++i;
}
strcpy(string, buf);
free(buf);
}
Yours Sincerely,
Jori.
When I use this function, I get the following output:
runtime error R6002
- floating point support not loaded
Note:
- safeMalloc() is a safe function with error handling.
- sizeof(string) >= sizeof(buf) (so no overflows)
/*
* Encode a string according to http://tools.ietf.org/html/rfc3986#section-2.1.
*/
void urlEncode(char *string)
{
int i = 0;
char *buf = safeMalloc(((strlen(string) * 3) + 1) * sizeof(char));
buf[0] = '\0';
while (string != '\0')
{
if (isalnum(string) || string == '-' || string == '_' ||
string == '.' || string == '~' || string == ' ')
{
if (string == ' ') string = '+';
sprintf(buf, "%s%c", buf, string);
}
else
{
sprintf(buf, "%s%%%.2X", buf, string);
}
++i;
}
strcpy(string, buf);
free(buf);
}
Yours Sincerely,
Jori.