Thread: Help with writing a pthread program in C

  1. #1
    Registered User
    Join Date
    Sep 2019
    Posts
    2

    Help with writing a pthread program in C

    Create a text file which contains 5 names, 5 ages’, and 5 cities. Each word and number should start in a new line as shown below.
    Amber
    John
    Damien
    Paul
    Kyle
    sydney
    melbourne
    canberra
    perth
    darwin
    20
    23
    21
    32
    24


    I need to write a C program to read those 3 categories by using 3 separate threads and display them on the terminal. The lines that were displayed must be written into a shared memory location (RAM), which should be accessible from another process later.


    I tried this a lot but I cant get it to work. If someone could write the code for me that would mean a lot


    Thank you.


    sample output


    Amber from Sydney. Age: 20
    John from Melbourne. Age: 23
    Damien from Canberra. Age: 21
    Paul from Perth. Age: 32
    Kyle from Darwin. Age: 24




  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Modifying a pthread program to read multiple lines
    By ilovecoding321 in forum C Programming
    Replies: 1
    Last Post: 09-13-2019, 12:19 PM
  2. Replies: 5
    Last Post: 11-06-2013, 04:31 PM
  3. Writing a program that runs another program
    By danfawaz in forum Tech Board
    Replies: 5
    Last Post: 07-29-2012, 11:00 AM
  4. gmp/pthread program leaking memory. Why?
    By sadakatsu in forum C Programming
    Replies: 5
    Last Post: 03-01-2012, 08:34 PM
  5. Help in Pthread and Mutex program
    By besty in forum C Programming
    Replies: 1
    Last Post: 11-12-2010, 04:04 PM

Tags for this Thread