just wondering what is wrong..?

This is a discussion on just wondering what is wrong..? within the C Programming forums, part of the General Programming Boards category; #include <stdio.h> #include <time.h> char *ctime(time_t *clock) int main() { printf("todayz time is..%c ",ctime); }...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    227

    Unhappy just wondering what is wrong..?

    #include <stdio.h>
    #include <time.h>

    char *ctime(time_t *clock)

    int main()

    {
    printf("todayz time is..%c ",ctime);
    }

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    There are 2 misstakes:

    1. The function ctime cannot be used as a variable. In your main you need to declare a variable of type time_t, this should be passed to function ctime and the result can be printed.

    2. The main needs to return a value, it is of type int.

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    227

    Smile

    can you please show me an example... cause i understand better by example..... thanxx

  4. #4
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    523
    Try this
    Code:
    #include <stdio.h>
    #include <time.h>
    
    int main(void)
    {
       time_t lt;
    
       lt = time(NULL);
       printf(ctime(& lt));
    
       return 0;
    }

  5. #5
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    Code:
    #include<stdio.h>
    #include<time.h>
    int main(void)
    {
    time_t TheTime; /* declare a variable of type time_t */
    TheTime=time(NULL); /* get the time */
    printf("The time is :- %s",ctime(&TheTime)); /* pass address of TheTime to ctime and print the result */
    return 0;
    }
    oops beaten to it. but left it because mines commented
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  6. #6
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    523
    left it because mines commented
    Ouch...
    That hurt dude
    heh heh
    I do comment my real code though *excuses excuses*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debugging-Looking in the wrong places
    By JaWiB in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-03-2003, 10:50 PM
  2. Confused: What is wrong with void??
    By Machewy in forum C++ Programming
    Replies: 19
    Last Post: 04-15-2003, 01:40 PM
  3. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 12:01 PM
  4. Whats wrong?
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 07-14-2002, 02:04 PM
  5. What did i do wrong? Code inside
    By The Rookie in forum C Programming
    Replies: 2
    Last Post: 05-18-2002, 09:14 AM

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