GWatt's Profile User Rating: *****

Reputation: 262 Architect
Expert w/DIC++
Active Posts:
3,045 (0.99 per day)
01-December 05
Profile Views:
Last Active:
User is offline Today, 06:50 AM

Previous Fields

Who Cares
OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:

Latest Visitors

Icon   GWatt has not set their status

Posts I've Made

  1. In Topic: realloc distorting my data

    Posted 29 Mar 2014

    I'll be honest, I think it's highly unlikely that there's a bug in realloc. Could you post the code where you are modifying the PlanetRecord array? I suspect the problem is there.
  2. In Topic: Code works fine on Mac, not so well on Linux server. Help?

    Posted 27 Mar 2014

    After you've set a value you can rely on it beng there, but you never set the values contained by the array in the first place.
  3. In Topic: Code works fine on Mac, not so well on Linux server. Help?

    Posted 27 Mar 2014

    You haven't zeroed out the array containing your character counts. In C, you should not rely on any data being initialized to a specific value.
    The easiest way is to do this:
    int array[SIZE] = {0};
  4. In Topic: bash copy dir without cp-r or any variant

    Posted 21 Mar 2014

    Is there a reason that you don't want to use cp -r?
  5. In Topic: two way communication between child and parent processes in C(pipes)

    Posted 19 Mar 2014

    I noticed a few things.
    The first is that you are reading into char* that has not had any space allocated. By itself a char* does not have any storage associated with it. I would recommend just using a char array (e.g., char msg[100].) Related to this is that sizeof cannot give you the allocated size of a pointer. For that you will need to record the allocated size. However, you can use sizeof to determine the space taken by an array, which is one of the reasons I recommended using an array.
    The second is that you are closing file descriptors that you later try to use. Example: in line 25 you close writepipe[1], but you try to write to it in line 30. That's not going to work. You need to keep the pipes open until you are done.
    Third, you are not correctly using pipes. You can see the man page for a clear explanation and an example: http://pubs.opengrou...tions/pipe.html I'll summarize by saying that the pipe function takes an int[2] and sets each value to a file descriptor. The file descriptor in p[0] is the read end and the file descriptor in p[1] is the write end. You are creating two sets of pipes - which is correct since you don't want to have a data collision - but you are not using the pipes properly. You should do something more like this:
    /* assume p1 and p2 are properly initialized pipes. */
    switch(fork()) {
        case 0:
            /* child */
            /* insert communication here. You will be writing to p2[1] and reading from p1[0] */
            /* parent */
            /* insert communication here. You will be writing to p1[1] and reading from p2[0] */

    Finally, I would avoid calling the pipes reader and writer. All pipes have a read end and a write end, so it's confusing to label an entire pipe `reader' or `writer.' If you want to be super clear which end of the pipe should be used for what, I would just create four more ints (named pw, pr, cw, cr or something similar) and assign the pipe's file descriptors to the appropriate variable.

My Information

Member Title:
Age Unknown
Birthday Unknown
Years Programming:
Programming Languages:
C, C++, Objective C, arm assembly, Java, perl, scheme, python

Contact Information

Click here to e-mail me
Website URL:
Website URL  http://


Page 1 of 1
  1. Photo

    Biggie_smallz Icon

    04 Feb 2013 - 22:57
    Hello Gwatt can you please get back to me.. I need help with some scheme programming?
  2. Photo

    raghav.naganathan Icon

    17 Oct 2012 - 01:11
    Dude...before your reputation changes, I would like to tell you that it(256) is a perfect square :)
  3. Photo

    GWatt Icon

    27 Dec 2010 - 22:52
    @arob, I haven't used Java regularly in years. Most of what I do now is in C or scheme. However, there are several tutorials on this site and on others that should get you well on your way to learning Java.
  4. Photo

    arob Icon

    25 Dec 2010 - 23:31
    hey can u help to learn java .
  5. Photo

    GWatt Icon

    24 Jun 2010 - 19:59
    Pretty sure it has 4.
  6. Photo

    no2pencil Icon

    22 Jun 2010 - 20:06
    Where you plugged the phone, does it have four prongs or just two? I've had trouble using rotary phones on digital lines, other times it works flawlessly.
  7. Photo

    GWatt Icon

    30 May 2010 - 06:35
    Yeah, that did get removed in the upgrade. Oh and my rotary phone works fine. I use it in my dorm. It was simply our house lines that it doesn't like.
  8. Photo

    no2pencil Icon

    06 May 2010 - 01:13
    It's back! YAY!
    The phone I mean...
  9. Photo

    no2pencil Icon

    02 Mar 2010 - 03:47
    Hey man! Looks like after the upgrade you are no longer sporting the Rotary Phone...
Page 1 of 1