This isn't exactly stack over flow, but I started learning C today in the hopes of getting a better understanding for system programming.
the question is as follows

Write a program that reads the content of a file, and prints out all unique words from the file and their number of occurrences. [10 pts]




Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.


{'Lorem': 1, 'Ipsum': 1, 'has': 1, 'been': 1, 'the': 2, "industry's": 1, 'standard': 1, 'dummy': 1, 'text': 1, 'ever': 1, 'since': 1, '1500s,': 1, 'when': 1, 'an': 1, 'unknown': 1, 'printer': 1, 'took': 1, 'a': 2, 'galley': 1, 'of': 1, 'type': 2, 'and': 1, 'scrambled': 1, 'it': 1, 'to': 1, 'make': 1, 'specimen': 1, 'book.': 1}

Note: Your program should use fork() to read the file into sub parts and combine the contents together for processing. You can create as many forks as you want as long as you have more than one process.

my code is as follows and, I want to to call the function using fork(), any ideas on where I can start, I have already tried and i keep getting the code run multiple times

  • 15
    Do your own forking homework!
  • 6
    @Demolishun touche its naive of me to want, to be spoon fed but as you can see my plate is full and you arent helping by putting a knife to my neck.. wait why are we making cutlery puns, but am sure you C what I did there.
  • 1

    Maybe show what you actually did?
  • 0
    @Demolishun what I initially did was to call fork() right after declaring's my values, I assumed since it worked with simpler functions it out to work with this to. I then went down a rabbits whole trying to correct the error by trying to get the process ID (pid) and if pid=0 then it runs my code. honestly am not sure if that is what is required
  • 6
    Nonononono we stop right here. Nobody who's not trying to find a solution themselves here should be able to be a developer. We need to stop to feed these these halfass knowing sonofabitches. Search for it. Find it. Understand it. Make it. Go fuck yourself.
  • 2
    @KrayOlympus Either show the code or fork off. Seriously
  • 3
    That's a pretty pointless exercise. Actually, you would read the file in the main process because that's I/O limited anyway. And for the parsing, you wouldn't use processes, you'd use parallel threads because processes don't really make sense here.
  • 3
    Came here to ask why the hell it’s requiring you to use fork(), but @Fast-Nop beat me to it.

    Also, you forgot to post the code 🤦🏻‍♀️
    (Not that we’re keen on doing your homework for you.)
  • 0
    Sure, my rates are $150 an hour...
  • 1
    It's probably best to do the exercise first in one process and do the forking last.
  • 3
    Everyone wants to see the code they tried with the intent of not doing their homework for them, but once that code is posted *ahem* *post the code* everyone will be contributing through thoughtful or sarcastic comment.

    It is the way.
  • 0
    @bertramus This is the way.
Add Comment