Results 1 to 3 of 3

Thread: NEED help: Is this possible for C ++?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2014
    Posts
    95

    Question NEED help: Is this possible for C ++?

    hello guys good am/eve!

    I have a question and need answer if possible...

    in VB.NET

    this is the code

    Code:
    Dim _date as String = Date.Today
    
    label1.Text = " ' " & _date & " ' Record"
    or

    Code:
    Dim _date as String = Date.Today
    
    label1.Text = _date + " Record"
    output


    3/8/2015 Record

    in C++ is that possible?

    this is my target code

    Code:
    void printRecordFile( fstream &readFromFile )
    {
    	ofstream outPrintFile( "C:\\Record.txt", ios::out );
    }
    I want is if I call printRecordFile it will create a filename 03-08-2015_Record.txt

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Aug 2014
    Posts
    95

    Re: NEED help: Is this possible for C ++?

    bump!

  3. #3
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    679

    Re: NEED help: Is this possible for C ++?

    Yes, this is possible. This code will put into filname the file name in the required format
    Code:
    char filname[30] = "c:\\";
    time_t tim = time(&tim);
    struct tm *todate = localtime(&tim);
    
    	strftime(&filname[strlen(filname)], 15, "%m-%d-%Y", todate);
    	strcat(filname, "_Record.txt");
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2019 (16.7.4)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width