1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Change the file extension using C

Discussion in 'C' started by dearimranz, Jan 26, 2008.

  1. dearimranz

    dearimranz New Member

    Joined:
    Jan 26, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi there,

    I am working on a project where I need to change the extension of file using C. For example I want to change a ".dat" file and write it in the form of ".txt" file.

    Can someone help me with this. I will be very thankful.

    ,,,
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,287
    Likes Received:
    364
    Trophy Points:
    83
    Moved to C-C++ forum for better response.
     
  3. Salem

    Salem New Member

    Joined:
    Nov 15, 2007
    Messages:
    133
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Please don't PM me for 1:1 support.
    C doesn't care about file extensions.

    Code:
    FILE *in = fopen("file.dat","rb");
    FILE *out= fopen("file.txt","w");
    
    Then you can do whatever you want to read from the .dat file, and write to the .txt file.
     

Share This Page