rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You can just specify the file name on the apt-get command line, as in:
sudo apt-get install filename.deb
As for switching to root, do this:
sudo su -

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

I strongly suspect you have fried your controller, or the drives. Have you tried another drive to see if it is recognized?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

One thing you are missing is the comparison function. If you use such, then you can easily count the number of times it is called. The standard system call for quicksort is called qsort. Here is the Linux signature for it:

void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *));
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

From the Wikipedia quicksort article:

Quicksort, or partition-exchange sort, is a sorting algorithm that, on average, makes O(n log n) comparisons to sort n items. In the worst case, it makes O(n2) comparisons, though this behavior is rare. Quicksort is often faster in practice than other O(n log n) algorithms.[1] Additionally, quicksort's sequential and localized memory references work well with a cache. Quicksort can be implemented with an in-place partitioning algorithm, so the entire sort can be done with only O(log n) additional space.[2]

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

As Adak said - without the code, there isn't much we can tell you. Usually these sort of problems are of the Homer Simpson variety - Doh! Head Slap! Once you see what is the issue... :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Here is a link to a video on the subject of installing NS2 on Linux: http://www.youtube.com/watch?v=F72OFQVcO00

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

Show what you are doing in pseudo-code, as well as tell us what algorithm you are trying to implement (bubble-sort, qsort, etc).

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There is a "convert" program that should do that for you. This link may help: http://www.partition-tool.com/resource/convert-fat32-in-windows-xp-and-vista.htm

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What deceptikon said, run FC in a virtual machine. You can download and install VirtualBox (www.virtualbox.org) free on any supported host (WinXP, Win7, Linux, et al) and run just about any x86-based system on it. Some new systems, especially those running Windows 8, are using the secure boot feature of UEFI, which makes installing other operating systems very problematical.

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

I think it would be something like this:

//Prototype
//iterator insert(iterator itr, const T& val);
template<typename T>
T& Vector<T>::insert(iterator itr, const T & val)
{
}

Assuming you want to return a reference to the actually inserted item.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

In your implementation here

template<typename T>
   Vector<T>::Vector(int num, const T& val = T())
   {
   }

You are trying to state it as a declaration, as would be in the header file. You need to do this:

template<typename T>
   Vector<T>::Vector(int num, const T& val)
   {
   }

Leaving the default value out of the signature.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Getting the ideas, and then implementing them, is part of your studies. Don't ask us to do your work for you! Just think about what YOU are interested in, and take it from there...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Like the Universe, this subject is infinite... Do a project/presentation on stuff you are personally interested in.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This is entirely specific to this device. Please refer to the manufacturer's web site for such support.

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

For a small or medium size business, a VPN (Virtual Private Network) is a reasonable solution. If that is not feasible, then a dedicated network link, with all systems inside the corporate firewall, is possible - which is the solution most larger enterprises utilize.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Also, if you are inserting a lot of data into a list like this, and need it to be sorted after every insertion, then calling qsort after each iteration is HORRIBLY inefficient! I use a head/tail optimizes insertion sort for that. It is a derivative of qsort, but the insert function puts the element in the correct position so the collection is sorted as you insert into it. It behaves much as would bsearch, and the only other overhead is the block move of the data down one element, and the occasional resizing of the array. Block moves are very efficient on modern processors, and an occasional realloc() is not too onerous. Obviously you don't want to do that on each insertion - I usually would do a binary realloc, starting with some reasonable power of 2 for the size of the array, such as 64 elements, and then double the size each time I need to reallocate it.

Here is some code that will tell you where to insert the element:

// Returns location and sets "where" reference to -1 if found.  Returns -1
// and sets "where" reference to insertion location if not found.
static int32 TSearch( const DataType** array,
                      const KeyType* key,
                      int32 count,
                      int32& where,
                      TCompareFunc compare )
{
    int32 mid = 0, low = 0, high = (count - 1);
    int comp = 0;
    where = -1;
    while(low <= high)
    {
        mid = (high + low)/2;

        // We compare in reverse since we are …
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

FWIW, I do use multiple kernels as well to test stuff out, and they are alternatives in my grub menu, so I can boot which I prefer, but they are generally just a point difference or two from what is the default for the system. Example, I run a Red Hat Enterprise Linux clone, Scientific Linux, with the current 2.6.32-279.19.1 kernel, but I also sometimes run earlier versions of the 2.6.32 kernel, such as 2.6.32-202, etc. As I suggested before, when I want to vett kernels that are very different (older or newer), then I install an appropriate base system in a virtual machine and start with that. VirtualBox (free/open source from Sun/Oracle) has worked well for me for about 6 years now. I use it on both Linux and Windows hosts.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

JorgeM is correct, except that normally it would be 253 IP's since the router gateway address will take at least one (usually 1 or 254) as 0 and 255 are special cases and aren't used for node id's.

Here is a good Wikipedia article on the subject: http://en.wikipedia.org/wiki/IPv4

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You can easily embed the output from a shell command into the argument list of another command using backquotes. Example, if you want 'y' to be passed as the option "--accept=", try this:

command --accept=`yes | head -1`

To get that into the standard input stream you can do this (scripting is best since it requires at least 2 lines):

command <<EOF y
EOF

# or

command <<EOF `yes | head -1`
EOF
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Use virtual machines to install/test new kernels first? I don't think that a 2.6.21 kernel will work with FC14 as there are SERIOUS deltas between the 2.6.2x and 2.6.3x kernels which require different user-side application versions to run. IE, won't work unless you also downgrade just about everything else on the system!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Mike2K, it is not the UI I cannot live with, but their changes in hardware support. With 9.04 and earlier, all of my hardware cruft (WiFi and Bluetooth dongels, broadband modems, etc) worked out-of-the-box - no configuration or driver installation required. Now, not so nice. If I have to deal with that krud, then I'll find another distribution to use (which currently is Scientific Linux) where at least I know where I stand/sit...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This is why you should wait before submitting your data to "the cloud". It isn't ready for prime-time as yet! I hope you kept backup copies of your data... :-(

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

So, you post some code. You don't indicate what your problem is (although there are a number of problems with your code)...

On writing to cout, terminate your lines with << endl;, otherwise you won't get your output displayed on the screen before you are asking for the input.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Usually, the x.04 (April) versions are LTS (Long Term Support) systems. If you want to have available updates then you need to install either the latest (and not necessarily greatest) version, or one of the LTS ones. Personally, I have not found an Ubuntu distribution that I can accept since 9.04. So, I am no longer using Ubuntu on ANY of my systems.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The IP address of your system cannot be changed by a C/C++ program in most cases. I have to ask, what exactly are you trying to accomplish?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

First, the first half of a palindrom is not the same as the second half. A palidrom is a word that reads the same forward or backward. This is something quite different! Here is a helpful Wikipedia article about them: http://en.wikipedia.org/wiki/Palindrome

I don't have time to review your code right now (need to go get dinner for wife), but you will likely need to adjust it in light of these differences.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Assembly language is TOTALLY platform dependent. IE, x86 code is very different from ARM code, from MIPS code, from Itanium code, PowerPC code, etc. Obviously, x86 is the currently most common denominator, so I would suggest that you purchase (or download) from the Intel web site the current x86 assembler reference documents. My last version is for pre-Pentium class processors so it wouldn't help much for modern processors.

FWIW, I don't know of any/many tutorials for assembly language programming, mostly due to the issues mentioned above. However, there may be some for the Intel x86 family of chips. In any case, here are some links that Google found for me:

http://users.ece.cmu.edu/~dbrumley/courses/18732-s12/docs/x86.html
http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html
http://www.csn.ul.ie/~darkstar/assembler/
http://www.hep.wisc.edu/~pinghc/x86AssmTutorial.htm

Enjoy!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

1) Install mono on your Linux system
2) copy you program .exe (for instance myProgram.exe) and associated dll from Visual udio onto the Linux.
3) In Linux type the command :
mono myProgram.exe
4) See ... what happens.

And good luck! Yes, mono provides a .NET VM for Linux, but much stuff won't work because they assume a Windows environment. As suggested, either use C++, or optionally recode in Java if you really need something that will work well on both Windows and Linux. I'd recommend Java for such cross-platform stuff - I have written a LOT of cross-platform C++ code for Linux/Unix/Windows that had to behave identically on all such systems, and it is not trivial to do. Java is a lot easier to accomplish that.

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

This is a case where you should pass a reference to the array you want to store the data in from the caller. Example:

void printUpperLetters()
{
    char upperLetters[26];

    ::memset(upperLetters,0,26);
    findUpperCase(upperLetters);
    for ( int i = 0 ; i < 26 ; i++ )
    {
         cout << (char)(i +'A') << " occurs "
              <<  upperLetters[i] << " times entered" << endl;
    }
}
void findUpperCase(char[]& upperLetters)
{
    infile.open("trytext.txt");
    char letters[MAX_LETTERS];
    int count = 0;
    while ( infile.peek() !=EOF )
    {
        infile >> letters[count];
        count++;
    }
    infile.close();
    for ( int i = 0 ; i < count ; i++ )
    {
        if ( letters[i] >= 'A' && letters[i] <= 'Z' ) 
        {
            upperLetters[letters[i]-'A']++;
        }
    }
}
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

My confusion - are you trying to connect with a telnet server, or becomee one yourself?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The telnet protocol has a complete conversation between client and server on startup. When you connect, it (the server) sends you queries about what your (the client) capabilites are, and you need to catch them and reply accordingly. That is so the server knows what to do when you send it data. All of this goes on before you get the login prompt. If you don't respond to them, then eventually it will time you out and terminate your connection. Since I have in the past implemented the complete telnet protocol (both client and server) for a real-time operating system (back around 1990), I can assure you that this is not trivial - not difficult, but not easy. First, you need to find documentation for the protocol on the internet (or pay big $$ to purchase the DDN white books, courtesy of the US Department of Defense), and then you need to implement the client side of the conversation. In truth, there isn't much you need to be able to do, but handling the "can you" queries is essential.

Have fun! :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

School work? :-) Please make an effort first, and then we will help you over the rough spots, but DO NOT ask us to do the work for you. Cheating is unethical and doesn't help you learn the subject!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You can do that on the command line like this:

#include <stdio.h>
int main(int argc, const char** argv)
{
    const char* pathToFile = 0;
    if (argc != 2)
    {
        fprintf(stderr, "Error - no wav file specified on command line\n");
        exit(1);
    }
    pathToFile = argv[1];

    /* Insert rest of code here */

    /* When finished, return 0 indicating program was successful. */
    return 0;
}
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Good question. Yes, you would have to iterate the array and call free on each element that was malloc'd. However, if this is the extent of your program, you really don't need to as the system will clear the heap for you on exit of the program.

tofumaker commented: thanks alot for the help, solved a problem i was struggling with for a few hours +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What mike_2k said, but understand that for an application to use the libraries you installed in /usr/local/lib, you will need to update the LD_LIBRARY_PATH environment variable to search there. IE, in your .bash_profile add this line:

export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib"

The reason for the {} around LD_LIBRARY_PATH is because you are using it recursively to redefine the LD_LIBRARY_PATH environment variable, so just using $LD_LIBRARY_PATH is not safe.

If you want libraries in /usr/local/lib to be found first, then switch the LD_LIBRARY_PATH and /usr/local/lib around, as in

export LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}"
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Try this:

    int x = 0;
    int buf[4];
    int* array[5];
    for (int i = 0; i < 5; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            buf[j] = x++;
        }
        array[i] = (int*)malloc(sizeof(buf));
        memcpy((void*)array[i], (void*)buf, sizeof(buf));
    }

    for (int i = 0; i < 5; i++)
    {
        int* temp = array[i];
        for (int j = 0; j < 4; j++)
        {
            printf("%d\n", temp[j]);
        }
    }

Bear in mind that some older compilers will object to the second outside for(int i = 0; i < 5; i++) as they don't properly scope the variable declared in the for() loop to just that loop.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I can't remember the sample size in WAV files, but I think it is 16 bits, which is a short integer in C. However, the bit order is something you need to determine, just in case you need to re-order the samples before uploading to the microcontroller. IE, this is called the BIG-ENDIAN vs. LITTLE-ENDIAN problem. That's something you would need to research. The C code is pretty simple to stuff the data into an array, and can be done in a single read once you know the size of the file, which you will use to size the array. Example:

FILE* fp = fopen(pathToFile, "r");
size_t sizeOfFile = 0;
char* rawbuffer = 0;
unsigned short int* sampleBuf = 0;
size_t bytesRead = 0;

/* Assume fopen succeeded.*/
fseek(fp, 0L, SEEK_END);
sizeOfFile = (size_t)ftell(fp);
rewind(fp);

rawbuffer = (char*)calloc(sizeOfFile, 1);

/* Assume calloc succeeded - but this may be an issue of the file is really big! */
bytesRead = fread((void*)rawbuffer, 1, sizeOfFile, fp); /* Need error checking here also. */

/* Assume read got all the data, in which case bytesRead == sizeOfFile*/
sampleBuf = (unsigned short int*)rawbuffer;

/* You now have an array of sample-size stuff. */
for (size_t i = 0, j = bytesRead / sizeof(unsigned short int); i < j; i++)
{
    unsigned short int sample = sampleBuf[i];
    /* Now, reorder sample if necessary and send to micro-controller. */
}

Bear in mind that this code is missing a LOT of necessary error checking and …

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

It may be a S3TC version issue, but you should install the dev package as well, especially if you built Steam from source.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Dihmen, please do not as people on the forums to do your homework for you! It is impolite, unethical, and just plain cheating!