I am using the following piece of C code to change file extension.
{
 #define EVAL_MAX_LEN (300)
 int nLen;
 char szOut [EVAL_MAX_LEN] = {0};
 char szPath [EVAL_MAX_LEN] = "/db/file/face.bmp";
 // Get string length !!!
 nLen = strlen (szPath);
 if ((nLen > 0) && (nLen < EVAL_MAX_LEN)) {
      while (nLen) {
           // Check for extension character !!!
           if (szPath [nLen] == '.') {
                szPath [nLen] = '\0';
                break;
           }
           nLen --;
      }//while (nLen ...
 // Create output file name and with new extension
 sprintf (szOut, "%s.txt", szPath);
 }// if ((nLen > 0) && (nLen < EVAL_MAX_LEN ...
}
Any suggestion for a better and more elegant code is welcome. I also know that in Windows we can use _splitpath to do this in an elegant manner. But right now, I am using this code in Linux.