rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Look at the code for VLC. What you want to do is very complex unless you just want to decode one variety of media. Personally, after 30+ years developing C code, and 20+ years C++, I would not try to do that without resorting to other API's to handle different media types (mpeg1/2 vs mpeg4 vs wmv, vs mkv, etc). You do say your are trying to make an MKV media player. That may be doable since MKV is open source and the specs are not patent-encumbered. Again, review existing open source implementations to help you understand what is needed to be done. I would advice that you go to www.videolan.org (the VLC project site) for sources and help.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Just an aside, the C function to delete a file is unlink(filename) as is the REAL system shell program, which is unlink filename. IE, when you execute rm filename, in reality that is calling the 'unlink' program, or the unlink() function... Honestly, without looking at the 'rm' source code I'm not 100% certain which it uses. My best guess is that it uses the C function. :-)

The unlink() function as well as the unlink command just decrement the inode link count and remove the file from the current directory. Subsequent unlinks in the same directory will not do anything. This keeps you from issuing a gazillion unlinks to a file in one directory, causing the file to be physically deleted when it still has references from other directories or applications.

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

To expand upon what 'cereal' said.

Linux identifies files/directories by their inode. This is the ONLY authoritative identifier for the component. That allows Linux to have hard links to a file, so even if one instance is deleted, the file itself is not until all links are removed. Also, when an application opens a file, that link count is increased, decreasing it when closed. When the link count to an inode (physical file) reaches zero, then, and ONLY then, will the file be physically deleted. This allows you to delete a file when some application is using it, which you cannot do in Windows. Once the application is done with the file, then the OS will remove it from storage.

So, consider the name/path of a file to only be a reference to the real file, which is identified by it's inode.

Just for your information (FYI), soft links do not increase the reference count to an inode, hence the occasional "missing link" with Linux.

-Rubberman

cereal commented: nice explanation +9
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

I assume you mean that your system partition is smaller than the physical capacity of the disc. There are two things you can do. One is to create a new partition (using the fdisk command) and creae a file system on that (mkfsys -t ext4 /dev/sda2 for example), then create a mount point on your regular file system and mount the new file system there. To make it mount when you boot, you will need to add the appropriate entry to /etc/fstab. The other way is to modify the partition containing the file system you want to increase to use the rest of the drive (assuming the space is adjacent to the partition in question, and doesn't have another partition in the way), and then resize the file system to use the additional space. Assuming your file system is an ext2, ext3, or ext4 file system, then you would use resize2fs to do that.

In ANY case, backup your critical data and file systems before you do any of this! If you do, the operation will go well. If you don't, something will go wrong and you will lose everything! This is Murpy's Law at work! Trust me, I know from personal, painful experience! :-) Also, remember that Google is your friend! The easiest way I know to do the backup thing on Linux is to get an external drive big enough to hold your entire system disc, then do a bit-image backup. If you mess up, then you can …

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Stack - you have a hole, and put things in it that are approximately the same diameter as the hole. IE, LIFO.
Queue - you have some beads and a string. You put one bead on one end, and take one off of the other. IE: FIFO.

Clear yet?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
  1. 2yy == yank the current and next line into a save buffer. You can then insert them with '2p' somewhere else.
  2. :2 == goto line 2 of the file.
  3. p == insert first line in save buffer (see #1 above) just below the current line.
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

If you are running on Windows and don't want to install Cygwin to get the GCC compiler directly, you can use MingW, which is an open source GCC implementation for native Windows applications. When it came out, TurboC/C++ was the bee's knees, but it is sorely dated now and not particularly standards compliant. GCC is a leader in standards compliance, hence portability.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Reminds me of cyphers I wrote back in the mid-1980's before I was comfortable with public-key encryption using large prime factors. Then I went and wrote a serious prime factorization tool so I could generate/decode Goedel numbers for radom strings... :-)

np complete commented: cool :) +3
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

What about my answer do you not understand? I thought I was pretty clear... Anyway, here is some further explanation of what I said.

When a user runs a program, they typically run in the user's account, with the user's privileges. The root user has full administrative access to the computer - it can do anything, access any file, etc. There are a number of attributes associated with all files on Linux, such as readable, writeable, executable, and a couple of other more subtle ones, such as the setuid attibute bit. All files/directories have an associated owner and group. There are bits that represent the readble, writeable, and execute attributes for each file and directory, for the owner as well as the group. What setuid means is that when the program is run, the program runs with the privileges of the owner, not the user running it. Since root owns the passwd program, when a regular user runs it, it is as though root was running it. Root also owns and has read+write permissions on /etc/shadow where the passwords are stored, so the passwd program can change your own user settings when you change your password. One way that the admin can make it so that no user can change their password is to remove the setuid bit on the /usr/bin/passwd program (NOT recommended).

I don't know if I can make it any clearer than that.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What happens when you reboot the computer?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Let's see if I understand what you want to do.

  1. Search a file.
  2. Find string1 that is followed in the same line by string2
  3. Follow string2 with string3, in the file, written back to disc?
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Some call C a "high-level assembly code" language, though it really isn't (in my opinion). Assembly language is as close as you will want to get to machine code. Do remember that each processor family has a different instruction set, and trying to do machine code on modern computer gear would likely be a great exercise in futility! :-)

The last time I wrote binary code was for a boot loader for an IMSAI 8080 S100 bus computer in the 1970's. Until we burned it to a ROM, we would input it via front-panel switches on the box. When executed, it would load CP/M from a floppy disc so we could do some real work, such as writing a clone of Space Invaders...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Here you are...

#include <stdio.h>
int main(void)
{
    printf("Hello World!\n");
    return 0;
}
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Some aspects of building a TCP/IP stack from scratch are very subtle. I have a "fond" memory of sitting in a small lab/office in an engine manufacturing plant in Indianapolis to debug and fix our OOB (Out-of-Band) message handling which wasn't working properly. Three solid 12 hour days of debugging, coding, testing... :-)

One thing that is absolutely necessary to understand the protocols and to code them is a complete understanding of finite-state machines (FSMs). It is impossible to implement them without using FSMs extensively. In such cases, either you have to write your own FSM handling code (which I did), or you resort to a lot of lex/yacc rules. My method was more efficient because I could tune the FSMs by editing a text file of rules and restart the applications/servers instead of regenerating C code with lex/yacc, recompiling, relinking, etc. The time I saved doing that was significant - we figure it cut a year off the development time. In 6 months we had a functioning system, and there were only two of us working on it. Most of our time was spent validating the state-machines by careful analysis of the RFCs in the White Books.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The TCP/IP protocol suite was formulated by the US Department of Defense's Defense Communications Agency and originally implemented by DARPA (Defense Advanced Research Projects Agency) in conjunction with the company Bolt Beranek Newman, Inc. in Cambridge Massachusetts. The specs are in the form of RFCs (Requests for Comments) in a set of very big books called the DDN Protocol Handbook. The most popular implementation is the Berkeley Sockets Library, written by the Berkeley Software Distribution (BSD) team at the Universiy of California, Berkeley. This is the source used by most Unix and Linux distributions. FWIW, I did a complete TCP/IP implementation for a real-time operating system, working solely from the DOD White Books, as the DDN Protocol Handbooks are called, back around 1990. The handbooks came out in the 1980's - my copy is from 1985, and it takes up a good foot of shelf space. Our implementation was able to communicate over ethernet to any system that had a TCP/IP protocol stack over ethernet, ranging from mainframe computers to mini-computers to PC's.

silvercats commented: woha +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The port number of the sending and receiving tasks are usually different. A server will listen on a known port, and when the client connects to it, it will provide an anonymous port to use for that connection.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You can also use a state machine to model this simple of an entity, which a DFD is at a fundamental level (sort of).

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

Another approach is to use the strtod(const char* nptr, char** endptr) function. You pass the string containing the number, and the address to a char* which will be set by the function to the first non-numeric character. FWIW, strtod() [double] and strtof() [float] will also accept scientific notation, such as 1.254e25. This is the technique I usually use, although I also will utilize an algorithm that walks through the string to check each character in some specific (rare) circumstances where I need to validate a particular numeric format.

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

Go to this web page (http://www.centos.org/modules/tinycontent/index.php?id=30) and select a mirror to download CentOS from.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Time to take it in to the "geniuses" at your local Apple store...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There is no standard hashmap for C, though there is for C++ (a template class). You are going to need to do the heavy lifting to implement this yourself, or find some open source code that implements it. As I have implemented such code in the past (not open source, sorry - belongs to Applied Materials now), I know something of this subject. First, you need to use a good hashing algorithm that will generate non-colliding key hashes. Those keys are then used to index the data records.

A good source of information on how to implement this stuff is Donald Knuth's "The Art of Computer Programming", volume 3, "Sorting and Searching".

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Private: This is only stuff that I can access directly or change.
Protected: This is only stuff that I, or my children (derived classes) can directly access or change.
Public: This is what I let the world access.

Then, we have "friends". Our friends can access/change private and protected elements that we have allowed them to. IE, I can allow a friend to come into my house and get beer out of the fridge, but not drive off in my car... :-)

Carpetfizz commented: why the downvotes? i think his analogy is pretty helpful... +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There are open source packages for voice recognition. As for whether or not they would be suitable for this purpose, I don't know. Try a Google search.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

It depends upon the Linux OS you are going to use. Myself, I prefer to have a pure Linux host OS, and then use a virtual machine to run Windows. This is MUCH more secure, and you don't need to reboot the system to run the virtual machine. I also, at work, do it the other way around, running Windows 7 as the host OS, and Linux in virtual machines. Our business applications are mostly in Windows, but my development work is exclusively in Linux (C, C++, Java, System R, Python, etc), so I run Red Hat Enterprise Linux 5 and 6 in virtual machines there. On my home/consulting workstation/server I run a clone of Red Hat, Scientific Linux 6, and run Windows XP in a virtual machine.

If you plan on running PC games, then use 64-bit Windows 7 for the host operating system. With today's multi-core CPUs and 8+ GB of RAM, you can easily (and happily) run Linux in a VM with 1 or 2 cores and several GB of RAM, and not impact your Windows applications much to speak of. Using a good virtual machine manager, such as Oracle's Virtual Box (free and open source), you can take snapshots of the system periodically, so if you really screw the pooch, you can instantly revert to the last saved snapshot, quite painlessly.

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

It is really in bad taste (and unethical) to ask people to do your homework for you. Make an honest effort to solve the problem, and we will be happy to help you, but you have to make a start.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

So, you are running overclocked at 3.77GHz, correct? This may be causing issues with bus I/O. Try resetting the clock to normal and see what happens. Also, your power supply may be failing. When you overclock a system, it sucks up more power.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

For simple C++ executables, you can just use the make command directly. So, if you want to build a simple C++ source file named my_application.cpp, you can just execute the command: make my_application
That will compile and link the executable for you quite nicely. A Makefile is unnecessary unless you have more than one source file to link.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Get this book: Algorithms + Data Structures = Programs
Author: Niklaus Wirth
Publisher: Prentice-Hall

Available from Amazon.com both new and used.

FWIW, Wirth was the inventor of both the Pascal and Modula programming languages. The original edition of the book used Pascal for the examples, but the content is applicable to any programming language. I've had mine since the early 1980's (it was first published in 1976), and I still use it. I am a senior systems engineer and software developer for one of the biggest cell phone companies in the world, am a published technical author, have software patents where I am credited as sole inventor, and am a director of an IEEE affiliate group. Let's just say that I live and breath software engineering... :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

All cell phones are trackable, using their unique imei number. That is registered with all cell towers in range of the device when it is turned on. That is what the "Find my iPhone" app uses to track your phone if it is lost or stolen. Even if the SIM is changed, the IMEI number is hard-wired into the phone. I don't think it can be changed.

Daniel Jones commented: Thanks rubberman +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Assuming you just want an internal network address, you need to go into the dhcp setup page on the local router and see what the dhcp address range is. Then you go into the network manager application on ubuntu and set the network interface to use a static address that is outside of that range. You will also have to set the netmask, dns, and gateway addresses, so before you do that, run the ifconfig command to see what those values are for the dhcp address you have now.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You don't indicate what voltage_min and voltage_max may be.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You are on your way to c++ coding mastery. As for keyboard input, look at some of the massively available open source code available. In the open source universe, there is no such thing as stealing (unless you don't give credit where credit is due!)... :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I wrote my first smart-pointer class in the early 90's which implemented a reference-counting garbage collection pattern. It is used for the most widely utilized manufacturiing execution systems software in the semiconductor, flat-panel display, and disc drive industries. In 10M lines of code, there are no deletes and no memory leaks. The hardest part was dealing with recursive (circular) references. So, what decptikon said - look at the implementation of the standard smart pointer classes/templates that are in the current C++ standard, and other frameworks such as Qt and Boost.

mike_2000_17 commented: 10M LOCs no deletes? That's how it should be! But, isn't there one delete in the smart-pointer definition? +13
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Just like human languages, once you are fluent in one it is unlikely that you will confuse it with another that you are also fluent in. I know a LOT of programming languages, and have never had a problem moving from one to another. If I don't use one for a long time, I like to have documentation handy for those niddling edge cases that can drive you to distraction. A good example of that is java, which I have been back to serious programming in after a 7 year hiatus.

In any case, I would agree that for simularity to C/C++ that php would be a good choice as a web application language. Another one good to learn would be javascript.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You have an explicit return before the end of the loop, so there is no looping going on. All of what VernonDozier said goes double for me.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Want a LInux laptop? Go to www.zareason.com - no Windows from them!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Try printing it out as hex first:

for (int i = 0; i < length; i++)
{
    if (i > 0) cout << " ";
    cout << hex << (int)buffer[i];
}
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Low price and good performance - AMD
Higher price and better/best performance - Intel

Xyzyxx commented: Sums it up perfectly :) +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

In this case, you already know the number of elements (min(100,sno1)) and size of each element (20). Use those values instead of the computed values, besides the fact that the size argument is not the size of a char*, but is 20. So, your qsort call should be this:

qsort(&list[0][0], sno1, 20, compare);

Also, your while function should read like this - skipping the copy part:

while((fscanf(data,"%s",&list[sno1][0]))==1)
{
    ++sno1;
}
el33t commented: Thanks! This solved my problem! +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The answer is ... it depends. It depends upon what operating system you run, what type of software you want to use with it, etc. Myself, I like nVidia, but principally that's because I mostly use Linux and there are better drivers for nVidia on Linux than for AMD cards. If you are just a "normal" user, then either will serve you well.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

On a mobile phone, the GPS won't use the data plan. However, the location functions on most mobile phones will use cell tower triangulation, or WiFi, to locate the device if it can't find enough GPS satellites to get a fix, or if the GPS is turned off. The WiFi won't add to the data plan, but the cell tower methods may - I'm not 100% sure of that however, and then I work for Nokia... :-) I'll have to ask some of our L&C (locations & commerce) experts to be sure...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This is where you start to learn how to write functions, use standard functions, and build related ones into libraries. Example, using your code to build on. Note that the function str2int(const char* numString) can be built into a library that you can link to any program you write, and then call from any related code.

#include <conio.h>
#include <stdio.h>
#include <ctype.h>

int str2int( const char* numString )
{
    int results = -1; // Default means not a number.
    if ((numString != NULL) || isdigit(*numString))
    {
        results = atoi(numString);
    }
    return results;
}

int main()
{
     char *buffer = 0;
     size_t numRead = 0;
     printf("Enter a number: ");
     fflush(stdout);
     buffer = getline(0, &numRead, stdin);
     if (buffer != 0)
     {
         printf("%d\n", str2int(buffer));
         free(buffer);
     }
     return 0;
}
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Internet address numbers and top-level domains are managed by the IANA (Internet Assigned Numbers Authority). These domain controllers share their data with each other, and as a new name/number comes on line, that information (routing information, etc) is passed around the internet so that eventually everyone can find it. Your country may have a TLD controller, but not necessarily. You might learn more her: http://www.iana.org/ or here: http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains