Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8845103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:39:24+00:00 2026-06-14T11:39:24+00:00

I finished the programming of a class project, but I still need to get

  • 0

I finished the programming of a class project, but I still need to get the running time. I tried clock() function, but it didn’t work.

int main()
{
  clock_t start_time=clock();
  (my codes)
  clock_t end_time=clock();
  printf("The running time is %f", end_time-start_time);
}

I guess this is the right way to use clock function, am I right? But I got nothing but 0.000000. Could someone tell me the right way? Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:39:25+00:00Added an answer on June 14, 2026 at 11:39 am

    clock_t is not a float, but an integer type, most probably a long.

    So you might use %ld to printf() it.


    Also clock() does not return seconds, but CPU ticks. So to get seconds the value returned by clock() shall be devided by the system constant CLOCKS_PER_SEC.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've pretty much finished coding a SIC assembler for my systems programming class but
I'm programming a BinaryTree project. I finished all (insert, delete, create, find) but one
So I finished my first C++ programming assignment and received my grade. But according
I finished my website and uploaded it to my webhost, but i get this
I always had trouble with estimating cost/price of finished software (or programming work), so
I finished learning the Big Nerd Ranch Guide to iPhone programming but now I
I am programming a client program that calls a webmethod but when I get
I just finished a semester up of C programming for a class I'm in,
I'm trying out Android programming for the first time since I just finished reading
Almost finished my java web app. All working fine. Whats next. I need now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.