Thread: need help in adding a charecter to the file name

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    3

    need help in adding a charecter to the file name

    Hello,

    if the account number is "abcd" then i need to have to check whether "abcd1" or "abcd2" or ...... is existing or not.

    if it is not existing then i need to create it.

    so how can i do this

    any suggestions

  2. #2
    Registered User
    Join Date
    Jun 2009
    Location
    US of A
    Posts
    305
    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.

  3. #3
    Registered User
    Join Date
    Sep 2009
    Posts
    3
    hello see i have an account name abcd already exixting in DB

    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

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by swathin2 View Post
    hello see i have an account name abcd already exixting in DB

    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.
    Last edited by Adak; 09-08-2009 at 05:54 AM.

  5. #5
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    hello see i have an account name abcd already exixting in DB

    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
    Could you be a little more vague, please? You use whatever API your database vendor supplies to negotiate queries.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  3. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  4. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM