rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

2 things:

  • power failures
  • power surges

These things are totally unforseeable. The only way to deal with power failures is with a good UPS. They are often accompanied with power surges. Only a good surge suppressor can deal with those. Also, when there are power surges due to lightning and such, then you also need to be sure your network/internet/modem connections are also protected. What is the cost if you don't? Total loss of data and system functionality. You might go for 3-4 years without any incidents, but when it happens, either you are protected, or you are toast!

FWIW, good UPS systems will also provide good surge protection, but you need to also protect your external internet (cable/dsl/modem) connections. Laptops have built-in power failure protection (their batteries), but when plugged into system main power, then you also need some external surge protection (a power strip with surge protection is usually adequate). For your desktop/side/underside workstations and servers? A good UPS is money well-spend, in my opinion.

One aphorism comes to mind with this - hope for the best, but plan for the worst!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

These graphics cards are very power hungry. Assuming your system still works when you remove the card, you need to verify that your power supply is adequate for the system + video card. If not, then you will experience the symptoms you are getting.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Wales - the location of the filming and production of the new Doctor Who, Merlin, and a bunch of other great TV shows! Hope to get there some day... :-)

P.S. My housemaster at Dulwich College in London where I spent a year (4th form) was from Wales, Mr. B.M.Jones! And for all of us ignorant Yanks, Jones IS a fine, respected Welsh name... So, if you are a Jones, then someone in your past was from that rocky shore!

P.P.S. I am partly a Roark, so my family hails from the Emerald Isle. In fact, one of my distant cousins was Mary Shelley, so I guess you could say that I am the cousin of Frankenstein... :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

For now I just want to remove Linux and install windows. May try dual boot when more knowledgable. How do I do a clean installation instead of an upgrade? Thx

As I said above, don't use the upgrade option. Use the clean install option. However, if your Windows disc is an upgrade disc, you may be SOL and need to purchase a full installation media... :-(

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This is not an upgrade. This is a clean installation. You don't upgrade Linux to Windows. If you have enough disc space, you can perform a dual-boot installation (install Windows first, and then Linux). Windows usually doesn't like to co-exist with Linux unless to tell it specifically to NOT use the entire disc.

So, do you want to remove entirely Linux and install Windows? Simple enough, just do a clean Windows installation (not an upgrade). It will happily blow Linux away and take over the disc. Then, if you really want to play with and learn Linux, you can install something like Virtualbox and run Linux in a virtual machine running as a guest OS under Windows.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You have a couple of problems. Mostly the variables that you pass to the cpu() and memory functions are being used as though they are being updated inside the functions, yet you don't update them there. Also, if that was your intention, then you need to alter the signature of these functions to this:

int memory(int adress&,int& data);
int cpu(int& number, int& data);

so you are passing the values by reference, then when you do this:

memory(x,y); 
write(pipefd[1],&x,5);

The value of x will be properly set and passed to the write() function.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

First, you declare Push() with this signature: void Push(StackType *Stack, StackElementType Item,int *k);
yet you call it like this: Push(&Stack,&Item,&k);
Do you see the problem? It would work if you called it like this: Push(&Stack,Item,&k);

As for the rest, read the error/warning messages - they pretty much tell you what is wrong. An important part of programming is being able to decipher compiler errors and warning messages so you can correct your program.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

RTFM. Use fork()/exec() functions to create a child process, which will then communicate with the parent process via pipes or TCP/IP connections.

In any case, start by modeling how the processor and memory will work/interact. Until you determine that behavior, anything else is a waste of time. FWIW, I taught a bunch of grade-school children how to build a stack machine (processor and memory) back in 1985, just like you are tasked with now. If they can handle it, you can too!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Well, your while condition is incorrect if you want to continue if xyz is even. The expression xyz%2 will return a non-zero value if it is odd, not even. So, try changing the while(xyz%2) condition to while ((xyz%2) == 0).

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Well, you can have vectors of vectors (to your specified number of dimensions), or you can create a struction with the needed dimensions. Locations have "locality of reference" - ie, a moving body (car/plane/train/bus/etc) will change it's locality, but in a temporal manner - so you might want to model that as well.

This is not a trivial problem. Sometimes, brute-force is the appropriate solution to a problem. My preference in such situations is to track the absolue current location, which requires some processing overhead to keep up-to-date (delete from last known position, and adding to current location). YOU need to determine what will be best for your needs! :-)

Again, this is a GREAT problem, and as I said, there is NO one best answer to deal with it!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Yes, to both questions. When inserting a new element into a sorted list (vector/array), don't just add it to bottom and try to re-sort the array. It is MUCH more efficient to find the position that it should be inserted in, move all the rest down one element (possibly requiring a reallocation of the array), and inserting it there directly. This is called an "insertion sort" algorithm. Bubble sorts are notoriously inefficient, especially when all but one element (or a few elements) are already in sorted order. There are methods that minimize this overhead, such as placing new elements (as you do) at the end of the array, but keeping track of the number of sorted elements, so a binary search which doesn't find the target will then go to the new elements and linearly search those. In such an algorithm, when the number of unsorted elements at the bottom of the array reach some maximum number, then the array is re-sorted and that is reset to 0.

Sorting and Searching - see the definitive Knuth volume on that (Google search appropriate here).

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

More information as to what specifically your use-case is would be helpful. I use vectors and lists for this all the time, but what pattern I utilized depends a lot upon what I am trying to accomplish.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Have you just tried to plug in mouse when system is powered down, and then booting it? It should recognize it and install the appropriate drivers; however, since just about no current mice use serial rs-232 interfaces, this may not work... :-( Time to get a USB mouse perhaps?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Sigh. I have built, and helped build a large number of PC's without problem (I am a certified computer hardware tech, and professional software engineer). That said, whenever I need to build a custom bit of gear for myself, I usually let my local white-box builder do it, because I know he won't give it to me until it works! I provide the exact specs, and he purchases the parts and builds it, and then burns it in. If it doesn't work, I don't pay! It costs me a very little more than doing it myself (which I am fully competent to do, but he charges me less per hour than my time is worth), and it eliminates all the headaches! Yes, I know, this is water under the bridge at this point... :-(

What is wrong? There are any number of possible causes for this, including not configuring the BIOS properly, a connector loose, an inadequate power supply, a munged power supply or other system components caused by the external video card drawing too much power when you originally turned it on ... or as you mention, incorrect jumper settings!

Anyway, I'm glad you sorted it out - good for you! I'm sure this was an "educational" process!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

A vector would be an option.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There is no guarantee that the ack gets back to the sender, as in the lost ack scenario. However, each packet has a sequence # and CRC, so the receiving network stack will keep track, especially if there are missing packets in between the ones it got. If it gets a duplicate, then it will discard the new copy, yet ack that as well so more don't get sent (hopefully). Naks are for packets that were received with a bad CRC. If the connection is really flaky, then it is possible that a duplicate will be received after the original one has been transmitted to the receiving application; however, the stack (driver) will STILL know that the current window has passed by the duplicate packet, and it will ack/discard it.

This is a problem at the network stack level - and not at the application level. I do network programming in high-volume, high-speed environments (multiple thousands of interacting systems world wide with 10 gigabit network connections internally, and multi-gigabit connections to the internet. This is NOT a problem! :-) It is a good school problem, however, which will impact hardware and firmware designers. My suggestion is that you develop a rigorous finite-state-machine representation of how to deal with this situation. I always find that it clarifies such edge cases very nicely.

FWIW, I have implemented a full TCP/IP stack for real-time embedded systems in the past (around 1990), so this is an issue I am intimately familiar with, and that …

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Your printArray() functions don't return anything, so there will be no operator << associated with them. Remove the outfile << in main() from lines 32 and 33.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What Moschops said. This is why we do exception handling (try/catch/throw) in C++. That will allow you to detect this sort of error and terminate after output of a meaningful error message that will help you fix the problem.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

If you have two microphones (built-in and external such as bluetooth, usb headset, or physical mic plugged into headphone/mic port), then the built-in may not be enabled. As suggested by AHarrisGsy, go to the device manager, right click on the microphone icon, and see if it is enabled. If not, change that.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

From what you say, if you are receiving duplicate packets, I can only assume that you are utilizing the UDP or other packet-based protocol, as opposed to a stream-oriented one such as TCP. The TCP protocol will discard duplicates - you should never see them. UDP will not discard them, and it is up to you to detect and discard them.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Your problem is that your first argument should be then entire command path, and the second an array of argument to pass to the command. IE,

const char* arglist[5] = {"arg1", "arg2", "arg3", "arg4", 0};
if ((err = execv("/usr/bin/cmd", arglist)) == -1)
.
.
.
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There is also 7zip which will generate standard zip-compatible archives. Win7 can also handle gziped files - at least it works for me. :-) So, what did you use to compress folder and contents?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Anyway, you posted an excellent question for newbie C/C++ programmers, and an area that a lot get wrong. Keep on trucking! :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Any* is an array of items of type Any (and use const char* in your examples, otherwise most compilers will complain). In effect, it is a pointer to the first element of the array, so that Any++ will point you to the next element in the array.

An array of pointers, such as Any* many[5], points to an array of arrays of Any items. Your example of const char* members[4] = {"Sally", "Alex", "George", "Martha"}; is such.

So, cout << array << endl; will output the line

some stuff

and cout << members[0] << endl; will output the line

Sally

If you do this:

cout << ++array << endl

you get

ome stuff

but if out do this:

cout << ++members << endl

you get

Alex

That is because in the last case, you are moving the pointer to the next member in the array of pointers, and in the previous case you are moving the pointer to the next member in that array of chars. Clear as mud, right! :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Is this for homework?

I would suspect so. At least they are making a reasonable effort to solve the problem, so helping them (at least as far as pointing out their errors) is not unreasonable, IMHO.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

FM (Farking Magic). :-) On Red Hat (RHEL and Fedora) systems, 32-bit libraries are installed into /usr/lib, and 64-bit ones in /usr/lib64. The system knows when an application is 32-bit or 64-bit and will load the appropriate shared libraries. If your colleague provides an RPM file for installation, then the yum package manager will deal with installing the dependencies for you. If it is in source or other (binary) form, then you will probably need to install the dependencies (32-bit versions) manually (use yum to do that where possible).

As for compilers, it doesn't matter. The 64-bit version of the gcc compilers will handle 32-bit code just fine.

Since you installed OpenCV via git (source code), if there wasn't a configure script (which should deal with 32-bit vs. 64-bit issues when generating the Makefiles), then you may have needed to modify the Makefile(s) to install the libraries into /usr/lib64, or /usr/local/lib64. I've run into this issue in the past for packages that were not configured to handle Red Hat or Suse distributions properly.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

VMware or VirtualBox - they are basically the same in that they allow you to run other operating systems in virtual machines on a single host. Myself, I like VirtualBox (open source and free) and use it on both Linux and Windows hosts. For my personal work, I run VBox on a Scientific Linux (RHEL clone) host, and for work I run VBox on a Windows 7 host. Not much difference that I can tell.

As Mike2k said, cross-platform development should be done on the system you are most comfortable with, and then recompiled and tested on the target platforms. I've been doing this for well over 20 years. Developing code that runs identially on Windows and Linux/Unix however means that you need to develop some good conditional macros that will "tag" classes and functions appropriately for Windows, but not for Linux/Unix (import/export etc). Also, if you want to build stuff that will conform to COM and such for Windows then there are more issues you will need to resolve.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Arrrgh! About 30 years ago I might have been able to help you, but the last time I had to deal with COBOL was around 1983... I have done all in my power to purge that knowledge from my brain since. :-) The only suggestion I can make right now is to visit our friend Google. Sorry! :-(

P.S. I even got rid of my COBOL and DIBOL books, around 1986 or 87.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

From the Linux fprintf() man page:

   The flag characters
       The character % is followed by zero or more of the following flags:

       #      The value should be converted to an "alternate form".  For o conversions, the  first  character  of  the
              output  string  is  made zero (by prefixing a 0 if it was not zero already).  For x and X conversions, a
              non-zero result has the string "0x" (or "0X" for X conversions) prepended to it.  For a, A, e, E, f,  F,
              g,  and G conversions, the result will always contain a decimal point, even if no digits follow it (nor-
              mally, a decimal point appears in the results of those conversions only if a digit follows).  For g  and
              G  conversions,  trailing  zeros  are not removed from the result as they would otherwise be.  For other
              conversions, the result is undefined.

       0      The value should be zero padded.  For d, i, o, u, x, X, a, A, e, E, f, F, g, and G conversions, the con-
              verted value is padded on the left with zeros rather than blanks.  If the 0 and - flags both appear, the
              0 flag is ignored.  If a precision is given with a numeric conversion (d, i, o, u, x, and X), the 0 flag
              is ignored.  For other conversions, the behavior is undefined.

       -      The converted value is to be left adjusted on the field boundary.  (The default is right justification.)
              Except for n conversions, the converted value is padded …
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Re Andrew's response - doh! Thanks! Brain fart there! Absolutely correct! I think I had just responded to a C query so brain was still in K&R mode, not E&S mode... :-) If I could vote down my previous post I would. :rolleyes:

From the department of excuses department: It was late when I read the post! I was tired! My glasses were dirty! Aren't all strings char* types? :lol:

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The code pName = &name should be either pName = name or pName = &name[0]. What you did was to take the address of the string which is already a pointer.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Please do not ask people to do your school work for you! First of all, it is cheating. Second, it is unethical. Third, it is theft (taking credit for someone else's work).

Finally, what program?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

As cereal mentions, to do this you need to encrypt the drive. There are a number of tools to do this, including TruCrypt: http://www.truecrypt.org/

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Your windows probably have an invisible border which is what the contact detection is triggered on. Check on the options for creating your windows to set the width of the border to 0 if possible, or 1 (pixel) if 0 is not an option. Optionally, if you can determine the pixel width of the border area, you can adjust your contact algorithm accordingly.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The wxWin tool set is a GUI library, but you can run any C or C++ code inside your wx functions. There are C functions which will run an external program and have the ability to pipe (as shown in the python example posted by vegaseat) the output to the calling process. You capture that output and stick it in an appropriate GUI widget.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

As Moschops said: ^ is not a "to the power of" - it is a bit-wise xor operation. Use the pow() function (or one of its siblings such as powf() or powl()) instead.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Windows XP, 7, or what OS are you using?

Usually, this is a DNS issue, which can happen if your ISP's DNS server isn't working properly. This has been an issue for me in the past. You can reconfigure your TCP/IP network settings to use another DNS server than the one that your DHCP device (router or ISP) provides. If you think this may be the case, I can provide some TLD (top-level comain) DNS server raw IP addresses that you can use to test this hypothesis.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Open the Control Panel "Sound" option. Click on the "Recording" tab, and look for an entry for the microphone. Click on that, and then click on the "Properties" button. At the bottom of the window you will see a selection entry with the label "Device usage:". Click on that and select the "Use this device (enable)" option. Then click either the Apply or OK button. Your microphone should now work, though sometimes you may need to reboot the system.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I only see one problem. That is where you print the random number. IE, you do this:

    i = random.randint(1,10)
    print random.randint(1,10)

but you need to do this, because the second line with the print statement will get a new random number:

    i = random.randint(1,10)
    print i

So in your case, the print statement will not reflect the actual number assigned to i. :-)

efwon commented: Thanks that makes sense. I know I wouldn't have caught that. +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

No mystery here. When it sees that a == 1, it returns immediately with a value of 1. It won't get to the list.append code.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

It should not be a problem. There are no static variables being accessed/changed inside the function that you may need to lock access to. Normally, function calls are executed on the stack, so each thread (worker) that has its own stack should not interfer with another. If the function accesses global memory, or local static memory, then a mutex lock or similar access gate would be required. In your example, this is not the case, so go wild! :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Have you specifically shared the printer? Are both computers part of the same workgroup?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

When booting, hold down one of the function keys (like F2, F12, etc) until you hear a bunch of beeps. That should force the system into the bios setup. Some systems have a special key to do this (Lenovo Thinkpads, for example).

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The most common type of recursion is what we call "tail recursion" - a function directly calling itself, which is what you are doing here. There is indirect recursion where a function A calls function B, which somewhere down the line agains calls to function A.

So, yes your FUNCTION is recursive. A recursive program is something else entirely... :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Depending upon the hash algorithm and the order of the table, collisions are common, so you have to traverse the chain to determine if you have a match if you are doing a lookup/comparison. With a sorted array, searches are nominally slower, but as deceptikon said, range searches and ordered output is a LOT simpler. I have written both types of collections in my past, and except for certain situations (random lookups, and low chance of collision), I have found that sorted arrays are preferable in the general case.

So, the rules are probably thus:

  • if you are doing random lookups and don't need range searches, use a hash table.
  • if you need to acces things in sorted order (range searches, etc), then a sorted array or some sort of B-Tree is preferable.
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Have you contacted the Apple iPhone/iOS support line? In any case, this Google search term, "ios upgrade ERROR 3194", returns a number of links to documents and videos on how to fix this problem.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Do some reading on reflection - the means by which you can use RTTI (runtime type identification) methods to do what you want. Google is your friend...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

As Mike2K said... You have a 32-bit system, but have somehow installed 64-bit versions of gcc and related cruft. You need to remove them all from the system and then reinstall the 32-bit versions of gcc et al.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Clean it up, then I'll comment. FWIW, I have done a LOT of research into prime number algorithms. They way it is written, it is very hard to read in a short period of time, which is all I have to give you...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I'd agree with gabeand - take the cover off and reseat all of the components. There may be other loose components (both socketed chips as well as expansion boards) that need to be reset in their sockets (RAM, flash/bios chips, etc). Also, check for loose screws.