Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 156901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:24:30+00:00 2026-05-11T10:24:30+00:00

I am using Linux GCC c99. I am wondering what would be the best

  • 0

I am using Linux GCC c99.

I am wondering what would be the best technique. To change a string. I am using strstr();

I have a filename called ‘file.vce’ and I want to change the extension to ‘file.wav’.

Is this the best method:

char file_name[80] = 'filename.vce'; char *new_file_name = NULL; new_file_name = strstr(file_name, 'vce'); strncpy(new_file_name, 'wav', 3); printf('new file name: %s\n', new_file_name); printf('file name: %s\n', file_name); 

Many thanks for any advice,


I have edited my answer using using your suggestions. Can you see anything else wrong?

/** Replace the file extension .vce with .wav */ void replace_file_extension(char *file_name) {     char *p_extension;      /** Find the extension .vce */     p_extension = strrchr(file_name, '.');     if(p_extension)     {         strcpy(++p_extension, 'wav');     }     else     {         /** Filename did not have the .vce extension */         /** Display debug information */     } }  int main(void) {     char filename[80] = 'filename.vce';      replace_file_extension(filename);      printf('filename: %s\n', filename);     return 0; } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:24:31+00:00Added an answer on May 11, 2026 at 10:24 am

    I would do this

    char file_name[80] = 'filename.vce'; char *pExt;  pExt = strrchr(file_name, '.'); if( pExt )   strcpy(++pExt, 'wav'); else {  // hey no extension } printf('file name: %s\n', file_name); 

    You NEED to do pointer manipulation in every c program. Of course you’d do some more checking for buffer over runs etc. or even use the path specific functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

linux gcc 4.4.1 C99 I am just wondering is there any advantage using the
I'm programming C using Linux gcc with -std=c89 switch. I have a variable storing
I have an application which i build using gcc on linux host for ARM
gcc 4.4.2 / Visual Studio C++ 2008 I have been using cmake on linux,
Compiling on linux using gcc. I would like to convert this to hex. 10
I am using gcc 4.4.2 on linux I am just wondering does gcc automatically
I'm fine working on Linux using gcc as my C compiler but would like
I have a c codes which can be compiled in Linux using gcc. But
I would like to cross-compile a simple program for ARM architecture using the arm-linux-gcc
Newbie to C. I'm writing an ANSI C program (on Linux using gcc 4.4.6)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.