Hi:
The problem is to conserve the base and change the extension.
In fact I can do this if only I had a list of the string manipulation functions. Then I'd worry about the files themselves. You can assume there is one and only one dot in the original filename (not a homework). Ideas:
Code:
name is a variable and extension a constant here.
[1. duplicate the pointer ]
p = name
[2. q points to '.' ]
q = find('.', p) + 1
[3. allocate mem to base and copy string beginning a p, in length
q - p, to base]
base = copy(p, q - p)
[4. concatenate base and extension]
p = append(base, extension);