Thread: Updating file name

  1. #1
    Registered User gazsux's Avatar
    Join Date
    Mar 2002
    Posts
    72

    Updating file name

    Hey,
    Ive written a program in c/opengl and it creates a .tga file of each frame to make a short animation. However, im wanting to 'update' the file name it creates in the function each time its called.

    eg:
    call 1: name=1.tga
    call 2: name=2.tga
    ...
    call n: name=n.tga

    How might I go about doing this?

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Code:
    #include <stdio.h>
    
    int CreateFile(void)
    {
      static int counter;
      char buf[BUFSIZ];
      
      counter++;
      sprintf(buf, "%d.tga", counter);
      
      puts(buf);
      
      return 0;
    }
    
    int main(void)
    {
      int i;
      
      for (i = 0; i < 10; i++)
        CreateFile();
      
      return 0;
    }
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User gazsux's Avatar
    Join Date
    Mar 2002
    Posts
    72

    Talking

    yeh! daddy cool it works, ty

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 04:27 PM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  4. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 10:57 AM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM