if the account number is a string in the way you are using it the strcat() function would do to change abcd to abcd1 , abcd2 and so on. Then you can search and if the result is null you can create a new account number.

and i need to get that account number from the DB and then check in a particular location that, that particular file is present or not like abcd1 or2 or 3...

and then suppose if abcd2 is present then it should create a new file by the name abcd3

like this it should go on

now i hope you can help me

I'm no pro, but I would use logic like this:

Code:

FILE *filePointer;
char filename[50]; //a string of char's with your filename,
//an end of string char ( '\0'), and no newline char ('\n').
filePointer = fopen(filename, "r");
//now check filePointer and see if a file was opened or not
if(filePointer)
//file was found
else
//file was not found (or could not be opened atm)

It's not all inclusive logic, since a HD problem or not enough file handles available, would cause fopen() to return NULL even when such a file did exist, but 99.9% of the time, it does the job.