How to make the file name being dynamic for my project?

Now i created a camera project with button, while i click the button the project will save a .jpg file inside SD card for me.
I use the example from my JPEGCAMERA library, it worked, so the problem for now is i cannot let my project save the .jpeg file with dynamic name.
Like from image00.jpg, image01.jpg… etc

these is my coding

/*
JPEG Camera Example Sketch
The sketch will take a picture on the JPEG Serial Camera and store the jpeg to an SD card
on an SD Shield
Written by Ryan Owens
SparkFun Electronics

Hardware Notes:
This sketch assumes the arduino has the microSD shield from SparkFun attached.
The camera Rx/Tx should be attached to pins 2 and 3.
IMPORTANT: The JPEG camera requires a TTL level shifter between the camera output
and the arduino. Bypassing this may damage the Arduino pins.
*/

//This example requires the MemoryCard, SdFat, JPEGCamera and NewSoftSerial libraries
#include <MemoryCard.h>
#include <SdFat.h>
#include <JPEGCamera.h>
#include <NewSoftSerial.h>
int sw=4;
//Create an instance of the camera
JPEGCamera camera;

//Create a character array to store the cameras response to commands
char response[32];
//Count is used to store the number of characters in the response string.
unsigned int count=0;
//Size will be set to the size of the jpeg image.
int size=0;
//This will keep track of the data address being read from the camera
int address=0;
//eof is a flag for the sketch to determine when the end of a file is detected
//while reading the file data from the camera.
int eof=0;
char name=“0.jpg”;

void setup()
{
//Setup the camera, serial port and memory card
camera.begin();
Serial.begin(9600);
MemoryCard.begin();
pinMode(sw,INPUT);
}

void loop()
{
int pbb=digitalRead(sw);
if(pbb==HIGH){
//Reset the camera
count=camera.reset(response);
delay(3000);

//Take a picture
count=camera.takePicture(response);
//Print the response to the ‘TAKE_PICTURE’ command.
Serial.write((const uint8_t*)response, count);
Serial.println();

//Get the size of the picture
count = camera.getSize(response, &size);
//Print the size
Serial.print("Size: ");
Serial.println(size);

//Create a file called ‘test.txt’ on the SD card.
//NOTE: The memoryCard libary can only create text files.
//The file has to be renamed to .jpg when copied to a computer.
MemoryCard.open(name,true);

//Starting at address 0, keep reading data until we’ve read ‘size’ data.
while(address < size)
{
//Read the data starting at the current address.
count=camera.readData(response, address);
//Store all of the data that we read to the SD card
for(int i=0; i<count; i++){
//Check the response for the eof indicator (0xFF, 0xD9). If we find it, set the eof flag
if((response == (char)0xD9) && (response[i-1]==(char)0xFF))eof=1;

  • //Save the data to the SD card*
    _ MemoryCard.file.print(response*, BYTE);_
    _
    //If we found the eof character, get out of this loop and stop reading data*_
    * if(eof==1)break;*
    * }*
    * //Increment the current address by the number of bytes we read*
    * address+=count;*
    * //Make sure we stop reading data if the eof flag is set.*
    * if(eof==1)break;*
    * }*
    * //Close the file*
    * MemoryCard.close();*
    * Serial.print(“Done.”);*
    }
    }[/quote]
    i have found 1 solution from Google Search :http://arduino.cc/forum/index.php?topic=120855.0
    so after that i changed few of my code:
    1. add #include <SD.h>
    2. char name[]=“image00.jpg”; instead of char name[]=“0.jpg”;
    3. and add this coding
    > for (int i = 0; i < 100; i++) {
    > name[6] = i + ‘0’;
    > name[7] = i +‘0’;
    > if (SD.exists(name)) continue;
    > MemoryCard.open(name);
    > break;
    > }
    instead of
    > MemoryCard.open(name,true);
    But while i compile my code, i get this error after the changes (because the error are very long which can exceed the maximum message allowed so i pick last few of line here:
    > C:\Users\Ellen\Documents\Arduino\001.arduino-0022\libraries\SD\utility\SdFile.cpp: In member function ‘int16_t SdFile::write(const void*, uint16_t)’:
    > C:\Users\Ellen\Documents\Arduino\001.arduino-0022\libraries\SD\utility\SdFile.cpp:1183: error: cannot call member function ‘void SdVolume::cacheSetDirty()’ without object
    But i can compile without error if without the SD.exist()
    so i suspect this could be the problem of my SD library.
    The arduino version i using is Arduino 0022
    I google search for the SD library and what i found is here:
    http://code.google.com/p/sdfatlib/downloads/list
    i tried all the library in 2010 but i was no luck. (i pick 2010 because Arduino 0022 are release on 2010)
    i also tried the newest version but came out another error.
    So what actually i need to do for solve this problem to get my camera able to save file with dynamic name?

You need to give name a size. File names can be 8.3 format so a size of 13 characters is enough (8+1+3+1). You need to declare name [13].

You also need to read all of Arduino Forum
and pay particular attention to
7. If you are posting code or error messages, use "code" tags

Pete