First off, your getFileName() function looks mighty complicated for simply returning a hardcoded filename. To simplify, it'd be better to use a #define. EG
>#define INPUT_FILE "myfile.txt"
(Oh, I see, just read your code a bit better, you want a number in the filename... )
To point out the problems with your code:
>char *temp2 = "";
>sprintf(temp2, "%d", in);
Here temp2 is defined as a pointer to a const string that is zero in length. So when you do the sprintf, the length of memory you have to play with is only one byte. Also, because it's defined as a string const (""), it will be placed in read only memory on some OS's.
The same applies for *temp1.
Also, you are returning a pointer to a section of memory that will go out of scope as soon as you leave the function.
Here's an improved version:
I left the function in there, but it's only one line long, so it'd probably be better to forget the function, and put the sprintf() in the loop in main().
#define MAXL_FILENAME 256
#define FILENAME "input"
#define FILENAME_EXT ".IWP"
void getFileName(char *buf, int in)
sprintf(buf, "%s%d%s", FILENAME, in, FILENAME_EXT);
FILE *data_file, *current_file, *temp_file;
int data, current;
char current_name[MAXL_FILENAME], data_name[MAXL_FILENAME];
for (data = 0; data < 99; data++)
current = data + 1;
printf ("name is %s\n", current_name);
Hope this helps....