rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

How are your building/linking this? The errors indicate that you are trying to link multiple versions (or copies) of the named functions, resulting in the "multiple definition" errors.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

:-) Yeah, asking us to analyze almost a thousand lines of code is a BIT excessive... :lol: Try to apply the KISS principal first, and then after you restructure your code, post again. :-)

That said, you are, to my mind at least, making good progress for a newbie at programming. Give yourself another year, and I think you might make a decent java programmer. Do remember that programming is NOT the same as software engineering. Work on studying the fundamentals, not just the coding constructs. See the books by Donald Knuth on software engineering as an example. They (all 4 volumes) are published under the title "The Art of Computer Programming". Also, another great one is Niklas Wirth's "Algorithms + Data Structures = Programs". Wirth was the author of both Pascal and Modula programming languages, and the graduate advisor of my college buddy (and still best friend) Bruce Ravenel - one of the co-inventors of the Intel x86 processor family.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

So little experience, yet you are writing ATM code? Please let me know what bank this is for so I can make sure to avoid their kiosks!

Mr.M commented: lol. Well with this code I have it easy to read as a person who has experience in programming and it also helped me to just see how I will go about writing these features that I want to add so you don't worry that much and if I get some problems I will po +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Re. What Stuugie said. We don't do peoples' homework for them. We will help once they make an honest attempt at it. Let's not help people cheat. Can you imagine what might happen if someone got through their degree courses that way, and then got a job in a safety-critical position? Can you spell "nuclear core meltdown", or "oh my god, that plane just fell out of the sky!"... ?

Stuugie commented: LMAO, "That plane just fell out of the sky!" +2
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The text is the code. Logic is how you apply algorithms (patterns for processing data) to data. This latter part is the difficult part. Image processing is VERY difficult. There are a gazillion factors to take into account, such as pixel depth (number of bits per pixel), size of image (x pixels vs. y pixels), shading, rendering, ray-tracing (if you are doing synthetic image generation), etc. My advice (after 30+ years doing this stuff) is to study well-written tools that do this. There are a plethora of tools in the FOSS (Free and Open Source Software) domain that do it. One great example is GNU's Gimp package. Study that. Understand that. And you may be ready to start writing some of this stuff on your own.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You are comparing a number with a string. Try Until num=-1 or something like that.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

One of the best texts on the subject is Comer and Stevens "Internetworking with TCP/IP". There are 3 or 4 volumes to the set, and they aren't cheap (running $30-100USD each these days - low price is for used volumes), but I refer to them regularly in my job as a systems engineer for a major network development organization.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

WiFi does not have such a range normally. In any case, you will need a number of bridges/repeaters. You can send from one repeater to another over a long distance using a Yagi-Uda directional antenna. I've used them in the past to bridge local WiFi transmitters over a distance of 100's of yards to over a kilometer. Bear in mind that you may well violate federal (FCC) power limits using this technology!

rch1231 commented: Short and to the point. +9
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Like C, C++ lets you get very close to the "bare metal" of your processor. Java is typically run through a virtual machine, which puts you one more level above the hardware - until you JIT (Just In Time) compile it to machine code! :-) As for "secure", well that is all relative (common for performance reasons). Java has many known security issues that make it possible (even easy) to subvert for malevolent purposes.

My personal opinion is that Java is really C++ with training wheels. It is easier for newbies to write code that is not directly exploitable, but it comes with a very high price. I write C, C++, and Java code for a living that impacts over 100 million users. I can do the same thing with C++ as Java, but the runtime overhead (memory and system overhead) of C++ (not speaking about performance or throughput - a debatable subject) is a LOT lower, and I don't have to worry about the JVM garbage collection performance impact (which can be mitigated somewhat, but at a very high development cost). If I need automatic heap reclamation of allocated objects, then I can use auto-pointers, or my own garbage-collecting smart-pointer classes. FWIW, I have been doing serious research in reference-counting garbage collectors for 20 years, and algorithms/code I invented and implemented runs most semiconductor manufacturing fabs on a 365x24 basis - over 10 million lines of code with no application-level deletes, and no memory leaks! If your device has …

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Consider a virtual machine as just that, a machine where you install an operating system and software. IE, you boot/install the OS you want in the VM and then install stuff you want to run on that "device". I run Linux on a VM on my work Windows 7 system, and run Windows XP in a VM on my personal Linux workstation at home, as well as Solaris, QNX, DOS, and other operating systems as needed, each in their own virtual machine (computer). The cool thing is that I can run more than one at a time, and with the network interfaces properly configured, I can communicate between them all.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

All well and good, being able to specify Linux/Unix file permissions with octal encodings, but these days there are much better options, such as the symbolic permissions supported by chmod, such as "chmod ugo+rw file/dirname", etc. Why force users to know octal permission encodings when they can use much simpler, and more easily understood, dialects? FWIW, I have been working with Unix since the early 1980's, and Linux since the 90's. I almost NEVER use octal encodings any longer for file/directory permissions any longer.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What cereal is says is that you should RTFM! Linux man pages are there so you can figure out simple stuff by yourself...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This is basic computer science. There are abundant resources that explain how to do this online or in the literature. Please DO NOT ask us to do your homework for you!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

FWIW, assembly language depends ENTIRELY upon the target processor. The assembly instructions for an x86 processor are totally different from an ARM chip, MIPS, uC, PowerPC, Sparc, etc.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

While Linux is not Unix, it is a Posix-compliant operating system, so most of what you learn about Unix is relevant. I have used both Unix and Linux (and related systems such as QNX) for many years. This is a good book - probably worth getting for general background information and knowledge. Kernighan was one of the original Unix developers at Bell Labs, and he was, with Dennis Ritchie, the author of the C language, still at the heart of most operating system development, especially Linux.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The time for any specific read/write function in a hadoop cluster and data node can vary significantly. I don't suppose you are running an industrial strength management tool like Cloudera on your cluster, are you? They do track those sort of metrics, and can alert you when they exceed specified limits.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Since this is in the subject "Shell Programming", I have to assume you are running some varient of Linux, and most likely the bash shell? Linux supports just about any character in a file name, including question marks. If an application wants to create a file with such a name, then it can (usually). The problem starts when trying to scan for these files in a bash script since question marks are wild card characters in bash. To match a real question mark, you have to "escape" them - preceed the question mark character with a backslash. The suggestion by rch1231 is not a bad idea. The rm command will ask you if you want to delete each file in that directory. The only problem is when there are a lot of files with those names. Given that Linux directories can easily contain hundreds, or even thousands of files, that could be quite tedious! :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Assuming that they both use the same video adapter type, such as DVI or vga, and your video adapter supports two of those types of displays, then you should be "golden". I use two slightly different monitors on my desktop (24", 1920x1200, DVI w/ nVidia 8800GT adapter), and except that the colors are just a little different (adjustment gets them close, but not exactly the same - a typical issue actually, even if the displays are "identical"), they work great!

That said, if your adapter supports 2 monitors, but one is DVI and the other is VGA, then as long as the monitors each support one of each, then that should work also. DVI is preferable to VGA from a performance and usability perspective.

aVar++ commented: Ok, that helped alot thank you. +2
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

All that said, I think that Eclipse CDT is a good tool, and if you need the hand-holding that an IDE provides, that is a great choice. I've used it in a number of collaborative development projects and it just works well. It is also cross-platform, so you aren't limited to Windows, which you would be with Visual Studio. If you are ONLY going to program in the Windows ecosystem, then VS may be a better choice.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I'm old-fashioned. I like a good editor such as nedit (any X-windows system), gedit (Linux), notepad++ (Windows), and make, plus a good debugger. I've used VS (many versions), and Eclipse (several versions), but they all get in the way of focussing on what you need to do, in my opinion. FWIW, I have been doing C++ programming for over 20 years, originally as principal engineer and architect for the company that wrote the manufacturing systems used by most semiconductor manufacturers in the world to run their FABs, and currently as senior systems engineer for a tier-one global tech company, I still use it extensively.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Indeed, there are times when auditing is appropriate, especially with systems that have enhanced security requirements. This is why there are the SELinux extensions (Security Enhanced Linux) and implements access control lists, and such. You might want to look into that.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What do you know of this subject? It is non-trivial. Do some google searching for more information, and don't expect someone with this sort of specialized knowledge to just "impart" it to you. Also, if you go to the Matlab web site, you might be able to find packaged solutions for these requirements.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

How do YOU think you use the newline() function?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There are any number of books and online articles that will help you understand object-oriented programming and methods. Anyway, which of these concepts don't you understand, and what do you think you know about them?

jalpesh_007 commented: good suggestion. +4
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Google is your friend. We don't give answers to school problems. If this isn't a school problem I'd still tell you to do a Google search. There are relevant articles on the Wikipedia, but in any case, you first need to understand reservation systems themselves: http://en.wikipedia.org/wiki/Computer_reservations_system

The above link is for airline reservation systems primarily, but the principles are the same.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

And your problem is? Please do NOT ask us to do your homework for you!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Do all this as root: sudo su -

  1. Create a partition and file system in that partition on the new disc - use ext3 or ext4 file system types.
  2. When you create the file system, specify a label such as "garrett": mkfs -t ext4 -L garrett /dev/snX1 where /dev/sdX is the new disc, and 1 is the partition number. The label will allow the system to renumber the device ids and still find the file system to mount at boot time.
  3. Create a temporary mount point, such as /mnt/newdrive, and mount the new file system there: mount /dev/sdX1 /mnt/newdrive - run df after you do that to make sure you see the new drive.
  4. Move /home/garrett to /mnt/newdrive.
  5. Create a new /home/garrett directory with the appropriate ownership and permissions - this will be the new mount point where the system will mount the new disk.
  6. Assuming you are using ext4 as the file system type, add the entry "LABEL=garrett /home/garrett ext4 defaults 1 2" to /etc/fstab.
  7. umount /mnt/newdrive
  8. mount -a

Now, you should see your data in /home/garrett. Log back in as garret, and everything should look like it did before, except that you will now be on a nice clean 250GB file system! The next time you reboot, /home/garrett will be mounted before the system comes up.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

A third way is to use a hash index. Once the hash is computed for the target value, it is usually a single probe to see if the value exists in the collection. The only thing that may interfere with that is a hash collision. I'm sure you can find some good articles on hash tables in the Wikipedia.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

if ((courses < 4) && (courses > 6)) is wrong. You want to verify if the courses variable is between 4 and 6, inclusive, so it should be if ((courses < 4) || (courses > 6)). IE, use the OR, not the AND boolean operator.

ddanbe commented: Good observation +14
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Here is a sample of code to test for a set bit. Adapt as necessary.

#include <stdio.h>
int main(void)
{
    unsigned char target_byte = 0x81;
    unsigned int i = 0; /* Always initialize variables - much safer! */
    for (i = 0x01; i <= 0x80; i = (i << 1))
    {
        fprintf(stdout, "Reading bit %.02x\n", (unsigned char) i);
        if ((unsigned char)i & target_byte)
        {
            fprintf(stdout, "Bit %.02x is set\n", (unsigned char)i);
        }
    }
    return 0;
}
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

IE (per Eagletalon), post some code that you think will implement your requirements, and then we may be happy to critique/correct/criticize it! :-) I am paid a 6-figure (in US Dollars) income to do this - don't expect me to just give you my time if you aren't willing to put something up-front as well!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

A lot of video cards suck up a HUGE amount of power, that many systems' PSU (Power Supply Unit) is incapable of handling - often over 100 watts. You need to verify that your system's power supply can handle the additional load.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Class members are part of a class instance. Where they live depends upon where the instance lives. If you declare an instance of a class as an automatic variable, then it is on the stack. If you allocate it with operator new, then it is on the heap. See example:

void sumFunction()
{
    SomeClass anInstance;   // On the stack
    SomeClass* pToAnInstance = new SomeClass;   // On the heap
    .
    .
    .
}
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What text book(s) are you using? There are some good ones out there that deal with this stuff. Generally, you tokenize the code, and then create a set of tree structures or finite-state-machine to represent the program. As you might infer from this, there is more than one approach that can work for you.

Two books that I have used in the past are Allen Holub's "Compiler Design in C", and Fischer/LeBlanc's "Crafting a Compiler". Both are on my shelf. FWIW, between the two of them, they take up almost 4 inches of shelf space... :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

At a minimum, 10xsizeof(double*). The size of a pointer depends upon whether you are running in 32-bit or 64-bit mode. The easy way to tell is to execute the function/macro sizeof(p1).

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Do this instead:

using namespace std;
string somestuff;    
cin >> somestuff;
cout << somestuff << endl;

As Tumlee said, what you did was not only unsafe, but guaranteed to segfault! A pointer has to point to valid memory. You had two major problems:

  1. The pointer was not initialized.
  2. Even if it was initialized to 0 (null) it would not be a valid address - writing to it would dump core.
  3. Even if it was initialized with a valid pointer to data, using such as new char[256] the input could still overflow the buffer. The C++ string class will deal with all of that for you. :-)
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Another approach would be to see if stdin is attached to a real terminal. A process that is spawned by a daemon would have no stdin device, or it would be /dev/null.

boomerang2711 commented: never mind.. i got it! +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You aren't providing enough information to really help you. That said, put the data set structures (you are using structures aren't you?) or strings, or whatever, into an array. They use a random number generator to randomly select items for the test set, and put the rest into the training set.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

LastMitch's ending comment is correct, but normally, even with Acrobat Pro, you will need the password to change the security settings on the document.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Send it back for warranty repair?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

And, what do YOU mean by the term "convert"? Do you mean to print it out as binary 0's and 1's? Or, something else?

tux4life commented: Good observation ;) +13
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You posted this in the C language forum, yet you are using C++ constructs. Is this supposed to be in C, or in C++? Or does it not matter?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Try the command "uname -r" - if you have a 64bit system, there should be an x86_64 in the kernel name string that will print. Ditto, look at the files in /boot. There are a number of other methods as well, but this will work. This will tell you if the OS is 32 or 64 bit, but it WON'T tell you if the hardware is 64-bit capable if it is running in 32-bit mode.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

First of all, this is VERY old K&R style code. Most modern compilers will emit a lot of warnings and possibly errors unless your compiler has a flag that will tell it that this is old code. Second, deceptikon is correct. Asking people to comment an 800+ line source file is unfair. It also deprives you of analyzing the code and understanding what it does. Just keep going through the code, line by line, and as you understand what it is doing better, add your own comments. That is how you learn. Code analysis is something that all software engineers and programmers have to do, otherwise there is no way they can modify someone else's code to fix bugs, add features, or write something similar but different.

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

The colon and following space are just text which will be ouput along with the variable data which will be inserted in the string where the format specifiers are found (%2d and %3d).

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

One word - Steam. Physics engines are very difficult. If you want to do your own, you will need to work on your maths (calculus) skills. Anyway, remember that Google (search) is your friend! :-) And do have fun!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Your code is totally wrong! The strcmp() function returns 0 if the elements are equal, < 0 if the left-side is alphabetically < than the right, and > 0, if otherwise. IE,

 if(strcmp(clr,"green") == 0) 
        printf("green");

etc. From the Linux strcmp man page:

STRCMP(3)                  Linux Programmer’s Manual                 STRCMP(3)

NAME
       strcmp, strncmp - compare two strings

SYNOPSIS
       #include <string.h>

       int strcmp(const char *s1, const char *s2);

       int strncmp(const char *s1, const char *s2, size_t n);

DESCRIPTION
       The  strcmp()  function  compares  the  two  strings  s1 and s2.  It returns an integer less than, equal to, or
       greater than zero if s1 is found, respectively, to be less than, to match, or be greater than s2.

       The strncmp() function is similar, except it only compares the first (at most) n characters of s1 and s2.

RETURN VALUE
       The strcmp() and strncmp() functions return an integer less than, equal to, or greater than zero if s1 (or  the
       first n bytes thereof) is found, respectively, to be less than, to match, or be greater than s2.

CONFORMING TO
       SVr4, 4.3BSD, C89, C99.

SEE ALSO
       bcmp(3), memcmp(3), strcasecmp(3), strcoll(3), strncasecmp(3), strverscmp(3), wcscmp(3), wcsncmp(3)

COLOPHON
       This  page  is part of release 3.22 of the Linux man-pages project.  A description of the project, and informa-
       tion about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/.

                                  2009-04-21                         STRCMP(3)
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

The algorithm won't change - only the language. Consider Banfa's post as pseudo-code and convert that to assembler... :-)