Find the answer to your Linux question:
Results 1 to 7 of 7
Hello! I'm new to this forum. I really suck at C/C++ and I was wondering if anyone can help me with two programs. 1) Write a program in C, which ...
  1. #1
    Just Joined!
    Join Date
    Nov 2008
    Posts
    3

    Help with a program in C.

    Hello! I'm new to this forum.

    I really suck at C/C++ and I was wondering if anyone can help me with two programs.

    1)

    Write a program in C, which will create a child. The father and the child will communicate through pipes. The father will read words from the user, which he will then send to the child. The child will calculate the number of letters the word has and return that number to the father.
    When the user inputs the word "END", the child will terminate and the father will print the total number of letters from all the words given and then terminate.


    2)

    Write a program in C, which will create a child. The father and the child will communicate through pipes. The child will read letters from the user and send them to the father. The father will take those letters and turn them to lowercase if they are uppercase and the opposite and send the altered letter back to the child, which will print it. The two processes will finish if the user inputs the letters "Q" or "q".

    If somebody can help me with those 2 programs, I'd be indebted to them. Also, if possible, write a comment next to each command so I can understand what it does. The point is for me to understand the programs.

    Thank you, and I'll be waiting.

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    You want us to do your homework???

  3. #3
    Just Joined!
    Join Date
    Nov 2008
    Posts
    3
    It may seem that way to you, but I want to understand the programs. That's why I'm asking for comments next to the commands. Although I know some C, I'm lost when it comes to forks, pipes and threads.

    Besides, an expert in C can write those programs in like 5 minutes. So I don't think it's a big deal.

  4. #4
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    What Gerard said.

    We don't do homework for you, of course, and most of those of us who answer questions do so on the basis of "leverage"; a few minutes of our time will do you a world of good. That happens when you do these things:
    1. Read the documentation. In this case, read the man pages, as follows:
      Code:
      man pipe
      man socketpair
      man popen
      man fork
    2. Then, for each of those man pages, look at the end at the SEE ALSO section. Read each referenced man page. For some of those referenced man pages, you may only have to read far enough to realize that you don't need that man page.
    3. If you have any specific questions about what's in one of the man pages, come back and ask.
    4. Then write your code.
    5. If it doesn't work, gather exact error messages and exact other bad behavior, and post those things with your question. What would help would be to post the source code for a tiny program which illustrates the problem.

    Hope this helps.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  5. #5
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    an expert in C can write those programs in like 5 minutes.
    So hire someone. Pay him by the hour. It ought to cost you, oh, ten bucks if you're right.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  6. #6
    Just Joined!
    Join Date
    Nov 2008
    Posts
    3
    I think you've misunderstood me. I don't even study Computer Science. I'm an amateur. So the term "homework" doesn't quite apply.

    Anyway, thanks for your help. I'll read the manual files, although I don't know how much it will help me.

  7. #7
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    I'll read the manual files, although I don't know how much it will help me.
    If something in them doesn't make sense, come back and ask.
    I really suck at C/C++
    There's your problem. :) scroogle the following:
    Code:
    C tutorial
    You'll find several, one of which ought to be a good fit for you. This will help that old leverage concept.
    --
    Bill

    Old age and treachery will overcome youth and skill.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...