Assuming you have two strings, one with the filename, and the other with the new extension, you could always copy both strings into a third string with strncpy().