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 6913591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:14:17+00:00 2026-05-27T09:14:17+00:00

I dont know how can I make threads in C, i saw a review

  • 0

I dont know how can I make threads in C, i saw a review about pthread.h library but then i heard that its only for Linux OS, i have a function that its a timer, i want to created a thread with that function but i dont know either the library i need to use and syntax’s to write the code, if someone could provide me a simple code with threads, or tell me what things i need to put and the parameter of the functions.

Here its the function i create that countdown the specific time the user apply:
i need to make a thread with that function.

Function (Countdown):

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

void countdown(int second)
{
    int secs = 1;
    time_t unix;
    struct tm * timeinfo;
    time(&unix);
    timeinfo = localtime(&unix);
    int t1 = timeinfo->tm_sec;
    int t2 = timeinfo->tm_sec;
    int i = 0;

    while(1 == 1)
    {
       time(&unix);
       timeinfo = localtime(&unix);
       if((t1 + i)  == timeinfo->tm_sec)
       {
              system("cls");
              printf("Time left %d\n", timeinfo->tm_sec - t2 - second);
              i++;
       }
       if(timeinfo->tm_sec >= (t1 + second))
       {
           system("cls");
           puts("Your time its done");
           break;
       }

    }
}

int main()
{
    int limit;
    printf("How much time would you like (In secs): ");
    scanf("%d", &limit);
    countdown(limit);

    system("PAUSE");
    return 0;
}
  • 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-05-27T09:14:18+00:00Added an answer on May 27, 2026 at 9:14 am

    Here is a simple guide to WinAPI threads:
    http://www.cs.rpi.edu/academics/courses/netprog/WindowsThreads.html (Archived)

    That being said, C is a minimalistic language, does not have built-in threading like Java (nor the enormous extra libraries). It was meant as a general language to build on top of it.

    On Unix-like systems, there are system-wide standard C libraries beyond the ANSI/ISO standard, which are part of the POSIX standard, the pthreads are POSIX-threads.

    Windows C libraries are MS makes things their own way. You can use frameworks that provide multi-OS support like GLib or Qt (Windows, Linux, other *nix). There are also ports and compatibility layers to use POSIX facilities inside windows. Cigwin gives you a full POSIX environment besides the libraries, The MinGW compiler allows you to use ports of POSIX functions on top of Win32 layers.

    Frameworks like GLib and Qt are best to keep your code multi-platform, they hide the OS specifics, allowing a more general approach.

    GLib is part of the GTK libraries for GUI development, and Qt is also a GUI development framework but in C++.

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

Sidebar

Related Questions

I know there are many threads that talk about this problem but I don't
I don't know what's make wrong, my map can load, but the image on
i am trying to get some data, but i dont know how can i
From the question you can probably tell that I don't know much about code!
How can you make a background web request and then update the UI, but
i have a question, been stuck for a while, i dont know how can
Why in java (I dont know any other programming languages) can an identifier not
I don't know if I can use regex for this, but I want to
Other than that I don't know if I can reproduce it now that it's
I know this has been asked, but all of the threads I find do

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.