By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,955 Members | 1,294 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,955 IT Pros & Developers. It's quick & easy.

replace string

P: n/a
hi,
I have a url which is a char *

char * url = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";

when i send this URL to http server it was like -

"/url=/home/sumit/pacakges/myxml.xml"

but when it get by http server it convert '/' to '%2F' i have to
reconvert it to '/'
i did so many string operation but i did not get real string ,
still i am trying. can anyone please give me idea how to replace '%2F' to
'/'
Thanks


Nov 4 '08 #1
Share this Question
Share on Google+
17 Replies


P: n/a
Sumit wrote:
hi,
I have a url which is a char *

char * url = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";

when i send this URL to http server it was like -

"/url=/home/sumit/pacakges/myxml.xml"

but when it get by http server it convert '/' to '%2F' i have to
reconvert it to '/'
i did so many string operation but i did not get real string ,
still i am trying. can anyone please give me idea how to replace '%2F' to
'/'
char url[] = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";
char *p;
while ((p = strstr(url, "%2F")) != NULL) {
*p = '/';
memmove (p+1, p+3, strlen(p+2));
}

Note the change in the first line. Also note that this is not
especially efficient, nor tremendously flexible -- but it's what you
asked for, so ...

--
Er*********@sun.com

Nov 4 '08 #2

P: n/a
On 4 Nov 2008 at 17:02, Eric Sosman wrote:
char url[] = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";
char *p;
while ((p = strstr(url, "%2F")) != NULL) {
*p = '/';
memmove (p+1, p+3, strlen(p+2));
}

Also note that this is not especially efficient, nor tremendously
flexible
Talk about the understatement of the century - that's right out of the
Richard Heath Field school of efficiency.

Do you get a kick out of mocking new posters by trying to lead them down
the garden path with a deliberately silly solution Eric?

Nov 4 '08 #3

P: n/a
Sumit wrote, On 04/11/08 16:53:
hi,
I have a url which is a char *

char * url = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";

when i send this URL to http server it was like -

"/url=/home/sumit/pacakges/myxml.xml"
It may look like that, but if the string is defined using "%2F" then I
would expect that to be what is actually transmitted.
but when it get by http server it convert '/' to '%2F' i have to
reconvert it to '/'
i did so many string operation but i did not get real string ,
still i am trying. can anyone please give me idea how to replace '%2F' to
'/'
Show us your attempt. Doing this processing is not difficult, just scan
the string for a % and treat the following two characters as a hex
number representing the required character then copy the rest of the
string (whilst still looking for % characters). Of course, you also have
to decide what to do with invalid input.
--
Flash Gordon
If spamming me sent it to sm**@spam.causeway.com
If emailing me use my reply-to address
See the comp.lang.c Wiki hosted by me at http://clc-wiki.net/
Nov 4 '08 #4

P: n/a

"Sumit" <su********@gmail.comwrote in message
news:49***********************@news.sunsite.dk...
hi,
I have a url which is a char *

char * url = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";

when i send this URL to http server it was like -

"/url=/home/sumit/pacakges/myxml.xml"

but when it get by http server it convert '/' to '%2F' i have to
reconvert it to '/'
i did so many string operation but i did not get real string ,
still i am trying. can anyone please give me idea how to replace '%2F' to
'/'
The following might work. But you probably need a more general solution.

#include <string.h>

void fixstring(char *s) {
char *t,*u,*v;

t=u=s;
v=s+strlen(s)-3; /* Last possible %2F position */

/* copy chars from *u to *t, replacing %2F sequences with / */

while (*u) {
if (u<=v && *u=='%' && *(u+1)=='2' && *(u+2)=='F') {
*t++='/';
u+=3;
}
else
*t++=*u++;
}
*t=0;
}
Nov 4 '08 #5

P: n/a
"Bartc" <bc@freeuk.comwrites:
"Sumit" <su********@gmail.comwrote in message
news:49***********************@news.sunsite.dk...
>hi,
I have a url which is a char *

char * url = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";

when i send this URL to http server it was like -

"/url=/home/sumit/pacakges/myxml.xml"

but when it get by http server it convert '/' to '%2F' i have to
reconvert it to '/'
i did so many string operation but i did not get real string ,
still i am trying. can anyone please give me idea how to replace '%2F' to
'/'

The following might work. But you probably need a more general solution.

#include <string.h>

void fixstring(char *s) {
char *t,*u,*v;

t=u=s;
v=s+strlen(s)-3; /* Last possible %2F position */
This can make v invalid. You can get undefined behaviour just by
computing it. Having computed it you can't ask if u <= v (and get a
defined result) although it often works.
/* copy chars from *u to *t, replacing %2F sequences with / */

while (*u) {
if (u<=v && *u=='%' && *(u+1)=='2' && *(u+2)=='F') {
I like to write this sort of test like this:

if (u <= v && strncmp(u, "%2F", 3) == 0)

since it makes what is sought so very clear.
*t++='/';
u+=3;
}
else
*t++=*u++;
}
*t=0;
}
I now feel I must show an tell so I am not just being negative. I'd
write it like this:

char *decode_hex(char *dest, const char *src)
{
char c, *dp = dest;
while ((c = *src++) != '\0') {
int nc;
unsigned int uc;
if (c == '%' && sscanf(src, "%2x%n", &uc, &nc) == 1 && nc == 2) {
src += nc;
*dp++ = uc;
}
else *dp++ = c;
}
*dp = '\0';
return dest;
}

The return of the string is just for convenience in larger expressions
and separating the source from the destination (which can, of course,
be the same) allows the function to be used on unmodifiable strings.

--
Ben.
Nov 4 '08 #6

P: n/a

"Ben Bacarisse" <be********@bsb.me.ukwrote in message
news:87************@bsb.me.uk...
"Bartc" <bc@freeuk.comwrites:
>"Sumit" <su********@gmail.comwrote in message
news:49***********************@news.sunsite.dk. ..
>>hi,
I have a url which is a char *

char * url = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";

when i send this URL to http server it was like -

"/url=/home/sumit/pacakges/myxml.xml"

but when it get by http server it convert '/' to '%2F' i have to
reconvert it to '/'
i did so many string operation but i did not get real string ,
still i am trying. can anyone please give me idea how to replace '%2F'
to
'/'

The following might work. But you probably need a more general solution.

#include <string.h>

void fixstring(char *s) {
char *t,*u,*v;

t=u=s;
v=s+strlen(s)-3; /* Last possible %2F position */

This can make v invalid. You can get undefined behaviour just by
computing it. Having computed it you can't ask if u <= v (and get a
defined result) although it often works.
Yes I was wondering if there was a problem in the rare case where v becomes
(or would become) negative.

--
Bartc

Nov 5 '08 #7

P: n/a

Sumit <su********@gmail.comwrote in message
news:49***********************@news.sunsite.dk...
hi,
I have a url which is a char *

char * url = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";

when i send this URL to http server it was like -

"/url=/home/sumit/pacakges/myxml.xml"

but when it get by http server it convert '/' to '%2F' i have to
reconvert it to '/'
i did so many string operation but i did not get real string ,
still i am trying. can anyone please give me idea how to replace '%2F' to
'/'
Well, I could tell you exactly how to do it, but it might be easier
to use an existing library that can encode/decode URLs, which
appears to be what you want to do (the big advantage is of
course that you don't have to re-invent not just one wheel, but
dozens of them).

I hate to mention a specific one, but Microsoft (shudder!)
has something called "wininet" which is an API that works
with the DLLs that provide client/server Internet functions
to Windows Internet applications; there might be others available
for other systems if you look for them.

It really does look like you have a very specific system issue
that requires that URLs be encoded (because of the "reserved"
nature of certain URL characters), and if you find a suitable API,
you can just call a function to encode/decode the URLs as needed.

For some specific background info on the topic, you can
go to the original RFC 2396 by Berners-Lee...

---
William Ernest Reid

Nov 5 '08 #8

P: n/a
On Tue, 04 Nov 2008 18:31:35 +0000, Antoninus Twink wrote:
>On 4 Nov 2008 at 17:02, Eric Sosman wrote:
char url[] = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";
char *p;
while ((p = strstr(url, "%2F")) != NULL) {
*p = '/';
memmove (p+1, p+3, strlen(p+2));
}
...SNIP...
Do you get a kick out of mocking new posters by trying to lead them down
the garden path with a deliberately silly solution Eric?

I don't see anything silly in it, except if:

1) it is totally inefficient.
2) it does not handle the last %2F. I mean if %2F is at end of the url,
then will memove go beyond the array ?

--
www.lispmachine.wordpress.com
my email is @ the above blog.
Google Groups is UnBlocked now :)
Nov 5 '08 #9

P: n/a
On Tue, 04 Nov 2008 23:50:56 +0000, Ben Bacarisse wrote:
....SNIP...
I now feel I must show an tell so I am not just being negative. I'd
write it like this:

char *decode_hex(char *dest, const char *src)
{
char c, *dp = dest;
while ((c = *src++) != '\0') {
int nc;
unsigned int uc;
if (c == '%' && sscanf(src, "%2x%n", &uc, &nc) == 1 && nc == 2) {
src += nc;
*dp++ = uc;
}
else *dp++ = c;
}
*dp = '\0';
return dest;
}
The return of the string is just for convenience in larger expressions
and separating the source from the destination (which can, of course,
be the same) allows the function to be used on unmodifiable strings.


How about this ?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int slash_converter( const char* );
int main( void )
{
char url[] = "%2F%2Fhttp::%2F%2F%2F%2Fwww.google.com%2F";

if( slash_converter(url) )
{
fprintf(stderr,"Can not allocate memory\n");
exit(EXIT_FAILURE);
}

return 0;
}
int slash_converter( const char* pc )
{
const int SUCCESS = 0;
const int FAILURE = 1;

char REPLACE_WORD[] = "%2F";
const int REPLACE_WORD_LENGTH = strlen(REPLACE_WORD);
int INSIDE_MOD = 0;

char* new_arr = NULL;
const long arr_size = strlen(pc) + 1;

new_arr = malloc( arr_size + sizeof(*new_arr));
if( !new_arr )
{
return FAILURE;
}
while( *pc )
{
if( strncmp(pc, REPLACE_WORD, REPLACE_WORD_LENGTH) == 0 )
{
INSIDE_MOD = 1;
}

if( INSIDE_MOD )
{
*new_arr++ = '/';
pc += REPLACE_WORD_LENGTH ;
INSIDE_MOD = 0;
}
else
{
*new_arr++ = *pc++;
}
}
return SUCCESS;
}

--
www.lispmachine.wordpress.com
my email is @ the above blog.
Google Groups is UnBlocked now :)
Nov 5 '08 #10

P: n/a
arnuld wrote:
>On Tue, 04 Nov 2008 18:31:35 +0000, Antoninus Twink wrote:
>>On 4 Nov 2008 at 17:02, Eric Sosman wrote:
char url[] = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";
char *p;
while ((p = strstr(url, "%2F")) != NULL) {
*p = '/';
memmove (p+1, p+3, strlen(p+2));
}
>...SNIP...
>Do you get a kick out of mocking new posters by trying to lead them down
the garden path with a deliberately silly solution Eric?


I don't see anything silly in it, except if:

1) it is totally inefficient.
Any measurements? Against what alternatives? Describe
the use case more fully: How long are these strings, how many
"%2F" sequences appear in them, how many of them need to be
processed? How many strings must you process with the (as yet
unknown) faster alternative before you break even on the time
spent writing it?

Sorry for the rant, but phrases like "totally inefficient"
when unaccompanied by even the barest whisper of an estimate,
much less a measurement, are totally stupid.
2) it does not handle the last %2F. I mean if %2F is at end of the url,
then will memove go beyond the array ?
Yes it does, and no it won't.

--
Eric Sosman
es*****@ieee-dot-org.invalid
Nov 5 '08 #11

P: n/a
arnuld <su*****@invalid.addresswrites:
>On Tue, 04 Nov 2008 23:50:56 +0000, Ben Bacarisse wrote:
<snip>
[All about replacing %2F with '/' in a string.]
How about this ?
<snip headers and main>
>
int slash_converter( const char* pc )
An int returning function that is passed a const char * can only
compute an int based on that string. It can't change the string, and
it can't return a new string. This must be wrong.
{
const int SUCCESS = 0;
const int FAILURE = 1;

char REPLACE_WORD[] = "%2F";
const int REPLACE_WORD_LENGTH = strlen(REPLACE_WORD);
int INSIDE_MOD = 0;

char* new_arr = NULL;
const long arr_size = strlen(pc) + 1;

new_arr = malloc( arr_size + sizeof(*new_arr));
Two things. (1) Why can't new_arr be initialised with the value you
want it to have? You do that for all the other variables. (2) This
space will be leaked since you don't free it and you can't get the
pointer out of this function.
if( !new_arr )
{
return FAILURE;
}
while( *pc )
{
if( strncmp(pc, REPLACE_WORD, REPLACE_WORD_LENGTH) == 0 )
{
INSIDE_MOD = 1;
}

if( INSIDE_MOD )
{
*new_arr++ = '/';
pc += REPLACE_WORD_LENGTH ;
INSIDE_MOD = 0;
}
else
{
*new_arr++ = *pc++;
}
}
You need to re-work this to get rid of INSIDE_MOD. You set it to 1,
immediately test it and set it to zero again. Just put the code it
controls where you set it!
return SUCCESS;
}
--
Ben.
Nov 5 '08 #12

P: n/a
Eric Sosman wrote:
arnuld wrote:
>>On Tue, 04 Nov 2008 18:31:35 +0000, Antoninus Twink wrote:
>>>On 4 Nov 2008 at 17:02, Eric Sosman wrote:
char url[] = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";
char *p;
while ((p = strstr(url, "%2F")) != NULL) {
*p = '/';
memmove (p+1, p+3, strlen(p+2));
}
....
> 1) it is totally inefficient.

Any measurements? Against what alternatives? Describe
It restarts the search from the beginning of the url for each pass
through the loop. It should resume the search just after the point where
the previous search ended. I don't think that "totally" is justified;
depending upon the typical size of the search string and the probability
of finding "%2F", it might be a completely insignificant inefficiency;
but it is inefficient.

Nov 5 '08 #13

P: n/a
Eric Sosman <es*****@ieee-dot-org.invalidwrites:
arnuld wrote:
>>On Tue, 04 Nov 2008 18:31:35 +0000, Antoninus Twink wrote:
>>>On 4 Nov 2008 at 17:02, Eric Sosman wrote:
char url[] = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";
char *p;
while ((p = strstr(url, "%2F")) != NULL) {
*p = '/';
memmove (p+1, p+3, strlen(p+2));
}
>>...SNIP...
>>Do you get a kick out of mocking new posters by trying to lead them down
the garden path with a deliberately silly solution Eric?


I don't see anything silly in it, except if:

1) it is totally inefficient.

Any measurements? Against what alternatives? Describe
the use case more fully: How long are these strings, how many
"%2F" sequences appear in them, how many of them need to be
processed? How many strings must you process with the (as yet
unknown) faster alternative before you break even on the time
spent writing it?

Sorry for the rant, but phrases like "totally inefficient"
when unaccompanied by even the barest whisper of an estimate,
much less a measurement, are totally stupid.
Its worst case behaviour is Theta(n^2). There's a trivial
Theta(n) worst case solution, so there's no reason for
anything omega(n).

We're not told anything about the possible inputs, so assuming
they're always small and with a small number of '/' replacements
isn't necessarily justified. How inefficient is it? How long's
a URL?

Phil
--
We must respect the other fellow's religion, but only in the sense and to the
extent that we respect his theory that his wife is beautiful and his children
smart. -- Henry Louis Mencken (1880-1956), American editor and critic
Nov 5 '08 #14

P: n/a
On Wed, 05 Nov 2008 14:09:06 +0000, Ben Bacarisse wrote:
An int returning function that is passed a const char * can only
compute an int based on that string. It can't change the string, and
it can't return a new string. This must be wrong.

SO should I return void (which is what I thought earlier) but what if
there is some error in the process ?
Two things. (1) Why can't new_arr be initialised with the value you
want it to have? You do that for all the other variables. (2) This
space will be leaked since you don't free it and you can't get the
pointer out of this function.

ouch! I forgot to free(). Anyway, I am doing a static allocation.
Malloc() was used there because my friend wanted it anyway without any
solid reason :-\
You need to re-work this to get rid of INSIDE_MOD. You set it to 1,
immediately test it and set it to zero again.
Thats is intended because it will not be set to 1 most of the times. If
the comparison is false then it will simply go to next if-else clause.
2nd, there is anew problem now. I have to work on 19 different comparisons
instead of one. A URI has 19 conversion taking place e.g. %3F for a "?" in
URI. See the Percent-encoding_reserved_characters section here:

http://en.wikipedia.org/wiki/Percent-encoding

Just put the code it controls where you set it!
I don't know what you mean. Here is the new uncompilable code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void slash_converter( const char*, const int );
int main( void )
{
char url[] = "%2F%2Fhttp://google.com%2F";
const int arr_size = strlen(url);
slash_converter(url, arr_size);

return 0;
}
void slash_converter( const char* pc, const int arr_size )
{
char new_arr[arr_size+1] = {0};

char replace_word[] = "%2F";
char replacement = '/';
const int REPLACE_WORD_LENGTH = strlen(replace_word);
while( *pc )
{
if( strncmp(pc, replace_word, REPLACE_WORD_LENGTH) == 0 )
{
*new_arr++ = replacement;
pc += REPLACE_WORD_LENGTH ;
}
else
{
*new_arr++ = *pc++;
}
}
}

==================== OUTPUT ==========================
[arnuld@dune C]$ gcc4 -ansi -pedantic -Wall -Wextra slash-converter.c
slash-converter.c: In function ‘slash_converter’:
slash-converter.c:22: warning: ISO C90 forbids variable-size array ‘new_arr’
slash-converter.c:22: error: variable-sized object may not be initialized
slash-converter.c:22: warning: excess elements in array initializer
slash-converter.c:22: warning: (near initialization for ‘new_arr’)
slash-converter.c:33: error: invalid lvalue in increment
slash-converter.c:38: error: invalid lvalue in increment
[arnuld@dune C]$


Line 22: char new_arr[arr_size] = {0};

I really don't understand how this is variable size array when I am giving
the array size at compile time.
--
www.lispmachine.wordpress.com
my email is @ the above blog.
Google Groups is UnBlocked now :)
Nov 6 '08 #15

P: n/a
On 04 Nov 2008 16:53:03 GMT, Sumit <su********@gmail.comwrote:
>hi,
I have a url which is a char *

char * url = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";

when i send this URL to http server it was like -

"/url=/home/sumit/pacakges/myxml.xml"

but when it get by http server it convert '/' to '%2F' i have to
reconvert it to '/'
i did so many string operation but i did not get real string ,
still i am trying. can anyone please give me idea how to replace '%2F' to
'/'
Thanks
Your native language is obviously not English. Because of that and
possibly just a general confusion, you have not asked *exactly* the
right question to elicit a good answer from many of the regulars on clc.
You are obviously confused about why the slashes are replaced by the
string '%2F'. You can get a fairly good explanation at
<http://en.wikipedia.org/wiki/Query_string>. The question and the
answer are slightly off-topic in this group, but I am glad to help.
------------------------------------------------------------------------

BTW, this reminds me of a joke.

A man in a small plane without instruments was en route to the Microsoft
airstrip when he encountered a heavy fog. After flying around for a
while he suddenly spotted a building, and a man peering out of a window.
He cut the engine and shouted across "Where am I?" the answer was
"You're in a plane." He knew immediately that he was at Microsoft
because he got an answer that was completely accurate, and deliberately
confusing.

This was originally told about IBM, before there was a Microsoft.
--
There is no one so stupid or ignorant
that I can't learn something from him/her.
Nov 6 '08 #16

P: n/a
arnuld wrote:
>On Wed, 05 Nov 2008 14:09:06 +0000, Ben Bacarisse wrote:
>An int returning function that is passed a const char * can only
compute an int based on that string. It can't change the string, and
it can't return a new string. This must be wrong.


SO should I return void (which is what I thought earlier) but what if
there is some error in the process ?
You're missing the point. Your program allocates memory for a new string
that contains the converted string, but the interface of your program
provides no way of letting the caller make use of that string. There are
two main possibilities:

char * slash_converter( const char* pc )

would allow you to return a pointer to the newly allocated string, and
to return NULL in case of any fatal error.

int slash_converter( char **out, const char* pc )

With this version, the user would create a char* pointer, then pass a
pointer to that pointer to slash_converter(). slash_converter would then
store the pointer returned by malloc() into *out.
>Two things. (1) Why can't new_arr be initialised with the value you
want it to have? You do that for all the other variables. (2) This
space will be leaked since you don't free it and you can't get the
pointer out of this function.


ouch! I forgot to free(). Anyway, I am doing a static allocation.
Malloc() was used there because my friend wanted it anyway without any
solid reason :-\
If you want the caller to provide the memory for the output string, you
can change "out" to "char*".

....
>Just put the code it controls where you set it!

I don't know what you mean. ...
Just replace:

if( strncmp(pc, REPLACE_WORD, REPLACE_WORD_LENGTH) == 0 )
{
INSIDE_MOD = 1;
}

if( INSIDE_MOD )
{

With

if( strncmp(pc, REPLACE_WORD, REPLACE_WORD_LENGTH) == 0 )
{
... Here is the new uncompilable code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void slash_converter( const char*, const int );
int main( void )
{
char url[] = "%2F%2Fhttp://google.com%2F";
const int arr_size = strlen(url);
slash_converter(url, arr_size);

return 0;
}
void slash_converter( const char* pc, const int arr_size )
{
char new_arr[arr_size+1] = {0};

char replace_word[] = "%2F";
char replacement = '/';
const int REPLACE_WORD_LENGTH = strlen(replace_word);
while( *pc )
{
if( strncmp(pc, replace_word, REPLACE_WORD_LENGTH) == 0 )
{
*new_arr++ = replacement;
pc += REPLACE_WORD_LENGTH ;
}
else
{
*new_arr++ = *pc++;
}
}
}

==================== OUTPUT ==========================
[arnuld@dune C]$ gcc4 -ansi -pedantic -Wall -Wextra slash-converter.c
slash-converter.c: In function ‘slash_converter’:
slash-converter.c:22: warning: ISO C90 forbids variable-size array ‘new_arr’
slash-converter.c:22: error: variable-sized object may not be initialized
slash-converter.c:22: warning: excess elements in array initializer
slash-converter.c:22: warning: (near initialization for ‘new_arr’)
slash-converter.c:33: error: invalid lvalue in increment
slash-converter.c:38: error: invalid lvalue in increment
[arnuld@dune C]$


Line 22: char new_arr[arr_size] = {0};

I really don't understand how this is variable size array when I am giving
the array size at compile time.
The value of arr_size is not known at compile time. arr_size is a
variable, and that's what makes new_arr[] a variable size array.

In your original version, your program filled in the array pointed at by
new_array, and then provided no way for the caller to access that array.
That was a memory leak. Your new version fills in an array named
new_array, which disappears at the end of your function, so you couldn't
even give the caller access to that array if you wanted to.
Nov 6 '08 #17

P: n/a
arnuld wrote:
>
.... snip ...
>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void slash_converter( const char*, const int );

int main( void )
{
char url[] = "%2F%2Fhttp://google.com%2F";
const int arr_size = strlen(url);

slash_converter(url, arr_size);
Think of it this way. You are passing a char* pointer and an
integer to slash_converter. You have told slash_converter NOT to
alter what the pointer points to, nor the integer (by the
'const'). You have told slash_converter not to return anything
(the void). So all slash_converter can do is spin its wheels and
waste time; it CANNOT affect anything else (other than global
variables, which it doesn't use).

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
Nov 6 '08 #18

This discussion thread is closed

Replies have been disabled for this discussion.