gettime from C to C++ ??

This is a discussion on gettime from C to C++ ?? within the C++ Programming forums, part of the General Programming Boards category; How do I write the in C++, it's should be called from a program a made i C++Builder, but I ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    64

    gettime from C to C++ ??

    How do I write the in C++, it's should be called from a program a made i C++Builder, but I can't call it when it is written in C.
    It comes up with a error:
    canot convert 'void *' to 'char *'

    I need to call a time function, which gets the time from the system.

    ---------------------code clip

    #include <stdio.h>
    #include <conio.h>
    #include <alloc.h>
    #include <dos.h>

    char* GetTheTime(void);
    int freeAllocated(void);

    char* GetTheTime()
    {
    char *Time = malloc(sizeof(char)*256);
    struct time t;
    gettime(&t);
    sprintf(Time,"The current time is: %2d:%02d:%02d\n", t.ti_hour, t.ti_min, t.ti_sec);
    return Time;
    }

    int freeAllocated()
    {
    char* CurrentTime;
    CurrentTime = GetTheTime();
    free(CurrentTime);
    return 0;
    }


    int main()
    {
    printf("HER er klokken \n\n");

    puts(GetTheTime());
    getch();
    printf("\n Saa free'er vi\n");
    freeAllocated();

    getch();
    return 0;
    }
    !G!

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    66
    Reply to this problem posted in the original thread, please stay in one thread instead of creating new ones to the same problem...

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    64
    I thought it was 2 seperated forums....
    sorry... I just needed to ask how it would seem in C++ instead of C.
    !G!

  4. #4
    Registered User
    Join Date
    May 2002
    Posts
    208

    use

    code statements when posting your source
    Jeff Paddon
    Undergraduate Research Assistant
    Physics Department
    St. Francis Xavier University

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 02-28-2010, 06:30 AM
  2. Counter (Time)
    By PickleBranston in forum C Programming
    Replies: 16
    Last Post: 02-10-2009, 01:00 PM
  3. Functions! Need help ASAP plz!
    By andone in forum C Programming
    Replies: 2
    Last Post: 11-02-2006, 04:07 AM
  4. time
    By cigcode in forum C Programming
    Replies: 6
    Last Post: 02-29-2004, 09:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21