how to triple space

Pages: 12
The first problem is that the OP hasn't specified the interface - other than it's using c-style strings.

For a function, is:

1) Modify the original string. Need the max size to which the string can be extended:

void tripleSpace(char* str, size_t maxSpace);

2) Create a new string in a given memory with a specified max size, keeping the original:

void tripleSpace(char* dest, const char* src, size_t destMaxSpace);

3) Create a new string in new allocated memory and return a pointer to new memory, keeping the original and caller has to free when finished with it:

char* tripleSpace(const char* str);

????????????
dhayden wrote:
The real problem with using strtok() is that it skips consecutive delimiters.

I did mention that particular issue:
http://www.cplusplus.com/forum/general/274506/#msg1184825

If that is a problem for the OP there are other methods to "triple space" a C string that can account for multiple spaces properly.
Topic archived. No new replies allowed.
Pages: 12