rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Ane we usually guard these with #ifdef DEBUG ... #endif /* DEBUG */ blocks so that you can turn the printf statements off when you are ready for production. Example:

void checkcollision()
{
    float x1 = tanks[0].x;
    float y1 = tanks[0].y;
    float x2 = tanks[1].x;
    float y2 = tanks[1].y;
    float dist = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
    float dr = tanks[0].rad+tanks[1].rad;
#ifdef DEBUG
    printf("dist: %f, radius+radius: %f\n",dist, dr);
    if(1 < 2)
    {
       puts("yes");
    }
    else
    {
       puts("wtf");
    }
#endif /* DEBUG */
    if(dist < dr) ;
    {
        printf("checkcollision read true\n");
        printf("dist: %f, radius+radius: %f\n",dist,dr);
        goback(0); goback(1);
    }
}

So, when you have a valid value, yet you don't get the output from inside the if (dist<dr) clause, then you know you need to look there. In any case, this sort of bug is common to beginners. Another one is to have single line contents of a conditional and not use curly-braces, so when you add code later that should be inside the conditional, it doesnt work correctly. Example:

        if(dist < dr) /* Note - no semicolon now */
            goback(0); goback(1);

This will be another bug since the second goback(1) will execute whether or not dist < dr. Rule: ALWAYS brace ALL conditional blocks of code, whether they are one liners or not. First, it is easier to read. Second, adding more code within the conditional will be less likely to result in inadvertant bugs.

One final thing. Do NOT, if at all possible, execute two separate statements …

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Not enough information. If you have a copy of the data, and you have root (admin) privileges, then you should be able to access any of that data.

Next, what do you mean by "recover user accounts". Recover data? Restore user account to active status on the system? What?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Also, providing the error output that you get is helpful as well. FWIW, the GNU Make documentation is quite good. Go here: http://www.gnu.org/software/make/manual/make.html

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Have you read the documentation and wikis on the lightsquid web site? Go to http://lightsquid.sourceforge.net/ for more information.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I've been using a pair to bridge my downstairs office with router, switch, and DSL modem to our upstairs WiFi access point and my wife's office switch for almost 5 years. No problems whatsoever.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There are books that go into this in detail. As a software engineer, I just use the appropriate macro functions that convert network-to-os order and vice-versa. I don't bother with the rest. That said, I used to teach basic internetworking to AT&T techs so I had to lecture on all of that cruft - a couple of days of 5 hour lectures and exercises just to deal with network addressing, bit/byte orders, and all that. You have a couple of days? I only charge $200USD / hour for that sort of training... :-)

P.S. They got college credit for the class.

BTW, is ANYONE still using Token Ring any longer? I still have some Arcnet boards laying around my basement if you want antique gear.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Just do one wait() in the parent process in a loop - not one for each child pid - until it receives the SIGCHLD signal for each forked child process. Waiting 3 times in the same while() loop is counter-productive. Alternatively, you can use waitpid() instead, to wait for a specific process to die.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
  1. Use << endl output manipulators after each output line so that the output is flushed to the display, and it appears on its own line.
  2. The loop is simple:

    while (soda != 6)
    {
    // 1. display menu
    // 2. decode input to decide what to do.
    // 3. done!
    }

Look at the switch() statement - that is better (in my opinion) than if/else if/else logic to handle this sort of situation.

So, keep at it - you are making progress!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Some C header files are not C++ safe. If you get compiler and/or linker errors when you try to do so, then "guard" the #include <someCheader.h> directives with extern "C" {...}. Example:

#ifndef MYCPPHEADER_H
#define MYCPPHEADER_H
// My C++ header file
extern "C" {
#include <someCheader.h>
}
.
.
.
#endif // MYCPPHEADER_H
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Please provide your definition of the dlist structure. I can infer it from the code, that that is not really reliable...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You can extract the specific file from the compressed .bz2 tarball with this command:

tar -jxvf filename.tar.bz2 targetfilename

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I don't see where you are setting the host ip address in your servadd structure. You are only setting the port. Example:

struct hostent* hostent = gethostbyname(pHost);
.
.
.
servadd.sin_addr = *((struct in_addr*)hostent->h_addr);
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Good employers don't place too much emphasis on "certifications", but on what you know and what you have done. If you are going to take a year to refine your skills, then sign up and start contributing to a serious open source project. In our organization, that would count for major points in the interview process, especially if you contributed some serious updates, bug fixes, enhancements, etc (stuff that can easily be verified). In my interview, I had to write on the whiteboard the C (or Java) code to compute a factorial. That was to prove that I knew how to write basic code, and had an understanding of recursion. I got the job, and am now senior systems engineer for a $40B company, working on bleeding-edge technology. I have no meaningful certificates, and indeed no actual degree. As the old saying goes, never let school get in the way of your education! :-) However, I do have a non-trivial software patent for adaptive systems software, am a published author in technical journals and a graduate-level IT text book, and have been an invited presenter at major IEEE and ACM conferences - all stuff that can be verified on the internet or with the organizations/publishers in question.

The only software-related certificate that I would consider getting these days is the IEEE CSDP - Certified Software Development Professional. That is the first step in becomming a certified PE (professional engineer) in software engineering. A PE is a government reecognized status which …

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What waltp said:

string getName()
    {
        cout << "What is your name? ";
        getline(cin, name);
        return name;
    }
WaltP commented: Do you ALWAYS have to reinterpret what's said before? Can't the post stand on it's own? -3
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

And you want us to fix your homework assignment? Sorry, but I have better things to do, like improve the browsing/web-apps performace for 50 million users...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

These files are probably DRM "protected" - most of us say that they are DRM-encumbered! IE, you don't own these books - you are only "leasing" them to run on "approved" hardware/software. There may be software that would enable you capture the audio on Windows and save it to another file in some more-or-less neutral format such as mp3, ogg, flac, etc. Unfortunately, I don't know what that would be. There are tools on Linux to remove DRM from DVD's and BluRay discs, so there may be tools for these files from audible.com.

Ok. I did a quick Google search, and this is what I came up with: http://www.kegel.com/linux/play-audiobook-on-car-stereo.html

It goes into some detail on how to capture .aax audio on a Linux system to mp3 files. The same techniques should work for ogg and flac (with minor adjustments).

Disclaimer: Breaking DRM or closed/copyright protected media (as is the .aax format) is against the law according to the DMCA (Digitial Millenium Copyright Act). You do so at your own risk! Ok, did my due-dilligence here. I, of course, have never done anything to violate the DMCA...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Another term for this (for serial rs-232 connections) is a null-modem cable. For ethernet cables, this would be called a patch cable.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Are you using a static address, or one dynamically generated by your ISP? In any case, using a VPN service (Virtual Private Network) will effectively mask your identity. There are a number of them out there. The most famous is Tor.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The Win32 API is a C api, not C++, so in order to apply object-oriented methods to it, you have to wrap it inside of classes. Qt and GTK (Qt more so) are good if you want to develop applications that can run on Windows, Linux, Unix, etc without modification (mostly).

Disclaimer re. Qt - I am a Senior Systems Engineer for Nokia, who until recently (last month or so) was the owner of Qt.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

IE: sum(div(x)) = x, and (sum(div(x) + x)/2 = x.

Obviously, the factorization of x is the key. I'm not 100% sure, but that may mean prime factors of x.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

From the Wikipedia:

n number theory, a perfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors excluding the number itself (also known as its aliquot sum). Equivalently, a perfect number is a number that is half the sum of all of its positive divisors (including itself) i.e. σ1(n) = 2n.

First, express the math as pseudo-code, then write code that expresses that in concrete terms. So, first show us the pseudo-code.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Not quite. You need to call the ofstream constructor with the name, which can be a variable. Here is the ofstream() constructor's signature:

 ofstream ( const char * filename, ios_base::openmode mode = ios_base::out );

So, as long as you construct the stream with a const char* file name, you are golden. Then, you can write to the ofstream object. Example:

void createAndWriteToFile( const char* vname, const char* somedata )
{
    char fname[MAX_FILE_NAME_LEN];

    // Construct file name here.
    sprintf(fname, "test/%s", vname);

    ofstream ostrm(fname);

    ostrm.write(somedata, strlen(somedata));
}
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There is a lot of stuff you are doing that has not been defined, such as the Info member/variable, the Pixel class, etc. Without that, debugging this is impossible. Also, have you built this application for debugging, and then run it in the debugger so you can see what is happening directly?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

As usual, mike_2000_17 gives awesome advice! :-) Mike, you have a LOT more patience than I do!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

BTW, the reason to not use alcohol is that it contains too much water already. You would need anhydrous alcohol (very difficult to find). Even the 90-95% alcohol that you can find in some pharmacies (normal rubbing alcohol is 70% - 140 proof), is not adequate. Anhydrous alcohol is 99+% pure, and sucks up H2O like nobody's business! You would have to get that from an industrial chemical supply company, and you would probably have to register the purchase with the authorities.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

That was basically what I was suggesting. Don't use alcohol. Go to your local computer store, or possibly office supply store. There you might find some sort of aerosol to dry wet electronics. It will contain some sort of non-invasive solvent which will adsorb the water and not affect the electronics when it evaporates. I've used such in the past when I was a computer repair tech, but that was a LONG time ago (about 25 years now). You might do a Google search to find what is sold today, and where to get it.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Use a switch statement on a variable representing the question you are at. Then, to return to a specific question, you can reset the variable to that question, putting all of this in a loop.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This:

typedef std::vector<Student_info> container_Student_info;

should be this:

typedef std::vector<struct Student_info> container_Student_info;

Of course, you could do this:

typedef struct Student_Info studentinfo_t;
typedef std::vector<studentinfo_t> Student_info_containter_t;

I like to put the trailing _t on the defined types so I know that these are defined types... :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

If I understand correctly what you are doing, then your professor is correct. The terminating condition of the loop is being able to read words from the input file. If you want to handle multiple files, then in the calling function (the one that calls pupulateStruct()) you will need to close the input file and open the next in another loop, inside of which you would call the populateStruct() function.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Really, you need to disassemble the phone as much as possible, and then use something like blow-dry (a volatile solvent that adsorbs water, and then evaporates quickly with the propellent it comes in, taking the water with it). Then, let the system sit open and disassembled in a warm, dry room for at least a day. After reassembling, it may work. If not, then you are going to need a new phone. I'd say your chances are less than 50/50... :-( FWIW, you need special tools to disassemble the iPhone.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You have assigned min from arraySize[0] before it was initialized. You are lucking that it was initialized to zero - it just as easily could have been garbage. So, change then initial assignment from min = arraySize[0] to min = 0, and then change the for() loop to determine min from for (i = 1; i < 5; i++) to for (i = 0; i < 5; i++)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

If undeclared/unimplemented, C++ will create default base constructor (no arguments), copy constructor, destructor, and assignment operator. The base constructor will do no initialization of variables whatsoever. The copy constructor will do a bit-wise copy of the copied data (member variables), as will the assignment operator. Often these are not safe. In any case, you should always create your own default constructor, and initialize all member variables. Example:

class foo
{
private:
    int a;
    int b;
    int c;
public:
    foo() : a(0), b(0), c(-1) {}
};
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Try changing this code:

else if ((!user.equals(uname)) && (!pwd.equals(password)))

to this:

else if ((user.equals(uname)) && (!pwd.equals(password)))
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I've done that in the past using raw sector editors. You usually have to boot into a live CD/DVD/USB system to do that, and it is very dangerous - you really need to know precisely how the file system is organized, and that is not always easy. All file system types are very different, such as FAT, NTFS, Linux ext2/3/4, xfs, ufs, zfs, etc al. Assuming you are referring to Windows systems, then you have FAT-16, FAT-32, and NTFS. With NTFS you may also have compressed or encrypted folders, which becomes another major issue. I have 30+ years of software engineering experience, including implementing file systems of various types, and even I don't bother with raw sector editing - the last time I did that was probably 20-25 years ago when I had no choice.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What are you using for an editor? Have you modified the file and directory permissions so you can save a new version of the file?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

MS-DOS was written in assembler, as was CP/M, TRS-DOS (for the TRS-80), et al. There is an open source version of DOS (FreeDOS) which certainly has a fair amount of assembler in it (it's mostly in assembly language). Here is a link to the download page: http://www.freedos.org/download/

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What distribution+version of Linux, and which kernel, are you running? This problem is usually due to a missing new-line at the end of the command stream. Edit the file, and add a new line at the bottom, then save the file and try again.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Sleep a bit before exit(0). I think you are running into a race condition and your parent is getting a SIGCHLD signal (you dieing) about the same time it gets the SIGUSR1 signal.

FWIW, using signals to communicate between processes is very dangerous and error-prone. It's use is common enough, but it is very easy to get into bad situations.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

As shown by np_complete, you can implement methods of a class inline, in which case you don't need to compile them as a separate translation unit. They are truly inline code, implemented in each translation unit that uses them.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Either C or C++ mostly, though Apple tools usually use Objective-C. You could use Java as well as other languages, but for efficiency's sake, C/C++/Objective-C are the preferred choices.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Exactly as WaltP says. You cannot compare a float with a double unless you down-cast the double, and even then it may not do what you think. Given the 64-bit systems we are mostly using these days, just use doubles if you need to compare computational results of floating point values. The only exception to that is if you need more than 64 bits of precision, in which case you can use long doubles if your compiler supports them.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Glad to help! :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

If you have a visible (static) internet address, then yes you can. If you don't then it isn't so easy. Contact your ISP about obtaining a static IP address if you want to host your own email (or other, such as web) server. It will cost you some extra $$ most likely.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You aren't providing enough information to help you. Please elaborate.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

int var = (x) ? y : z;
is equavalent to this:
int var; if (x) var = y; else var = z;

Do note that inline conditional statements like this can only reliably return an integer or compatible type, though you can return pointers with the appropriate casts. Caveat programmer! :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You can use iptables to further firewall your servers, and enable SELinux extensions (Security Enhanced Linux), which can very much harden your systems. SELinux was originally developed by the US National Security Agency, and is (or should be) used on all high-security government systems.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Basically, you are on the right track, but you need to make the member variables pointers, and don't instantiate them in the derived classes. IE, something like this:

class X {
A* m_myA;  
// I know this doesn't work due to the abstract definition, but this is my goal
public:
    X(A* myA) : m_myA(myA) {}
}
class Y : class X {
B m_myB;
public:
    Y() : X(&m_myB);
}
class Z : class X {
C m_myC;
public:
    Z() : X(&m_myC) {}
}

Then, change your access code from p_x->m_myA.foo(); to this: p_x->m_myA->foo();. That should do what you want, although it is a bit clunky...

sblass92 commented: Yep, works like I want, thanks! +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This bit of code isn't particulary useful in showing us how you are decoding the data. Provide more source code please.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

currentLink is pointing to head.next, which may well be null, hence the null pointer exception. Test it first using some code like this

if (null == currentLink)
{
    // have null pointer
}
else
{
    // Search or manipulate currentLink
}
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You need the class name before the method in the implementation. IE,

class cone
    {
          private:
                double radius;
                double height;
          public:
          cone();
          void setvolume(double r, double h);
          double conevol();
    };
    //implementation
    void cone::cone() : radius(0.0), height(0.0)
    {
    }
    void cone::setvolume(double r,double h)
    {
          radius=r;
          height=h;
    }
    double cone::conevol()
    {
           double vol=(1/3.0)*(3.14159265)*radius*radius*height;
           return vol;
    }

Note that I fixed a few other issues as well... :-)