JasonHippy 739 Practically a Master Poster

ls and rm are a couple of command-line/system programs in Unix and Linux operating systems, they aren't regular expressions.
ls is used to list the files/directories in the current directory and rm is used to remove/delete files.
As stated, ls -l lists the files/folders in the current directory. The l parameter makes ls list more detailed information about the items in the current directory.
Similarly rm -rf will delete files/directories. The r parameter makes it delete files recursively (so it will go into any subdirectories and delete files there too), the f parameter suppresses any confirmation messages (e.g. "Are you sure you want to delete this file? (y/n)") and forcibly deletes any files.
So using rm -rf will delete everything in the current directory and everything in any sub-directories.

Opening a terminal session as root and using the rm -rf command at the root of the filesystem is one sure-fire way of deleting everything on your Unix/Linux system. Which may be why some of your class laughed when they saw it. It's OK to use rm -rf if you want to remove a lot of files/folders, but you need to be very careful when doing so! (Again, just don't use it at the root of the filesystem or in any system directories when you have root priveleges!)
Even as an ordinary user, using rm -rf in the wrong place could delete all files that you have the appropriate permissions for (so all of your personal files, …

JasonHippy 739 Practically a Master Poster

Because you're passing rect by value into the area function, a copy of the Rectangle object is created inside the function using the default copy constructor (which will be automatically created by the compiler as you haven't created a copy constructor).
The first call to the Rectangle destructor occurs when it drops out of scope after your area function returns, destroying the local copy of the Rectangle.
The second call to the Rectangle destructor occurs when 'rect' drops out of scope when your main() function ends.
To avoid a local copy of the passed-in Rectangle being made, you could set the area function up to take a const reference to a Rectangle object instead.

Hope this clears things up for you!

edit: Damn, beaten to the punch again! Very quick as ever Mike!

lastbencher commented: Thanks :) +0
JasonHippy 739 Practically a Master Poster

With the ls command, the 'l' flag uses a longer listing format, 't' sorts by modification time and 'r' reverses the order of the sort.

To list folders recursively you'd need to use the 'R' flag!

Remember man pages are your friend.
To see all of the available options for the ls command use: man ls

JasonHippy 739 Practically a Master Poster

Mine's fairly self explanatory. My name is Jason and Hippy is a nickname my friends gave me many years ago. Partly due to the long hair and beard I've been sporting since my teens and partly due to the fact I was vegetarian back then!

I'm in my 30's now. The long hair is long gone and I'm not vegetarian anymore. But the nickname has stuck!

JasonHippy 739 Practically a Master Poster

Personally I use sudo on the command line for most administrative tasks on my Debian/Ubuntu based installs. Except if I have a lot to do, in which case I'll switch to root using sudo su .

You can open a root terminal using the command gksudo gnome-terminal In older versions of Ubuntu (10.10 and earlier) there used to be a launcher for the root terminal which you could add/enable in the system menu using the old gnome menu editor (alacarte). But since the shift from Gnome 2 to Unity from 11.04 onwards, I don't know if there is a launcher directly available (I'm not a fan of Unity, I use Xfce or Openbox as my default WM now!).

If the default key combination 'Alt F2' still brings up the 'run' dialog, you could use that to enter the command: gksudo gnome-terminal This should prompt you for your password. Then, if you entered your password correctly a root terminal session will be opened.

Otherwise, if the 'Alt F2' shortcut doesn't work any more (I've not used Unity very much, so I'm not that familiar with it. Did I mention I don't like it? Heh heh! ), you could try opening that new fangled 'dash' thing in the top left and then type the command in there!

And that should be OK for occasional use, but if you want to use a root terminal often and you don't want to type the command every time; you could try …

JasonHippy 739 Practically a Master Poster

In my experience most companies just want somebody who can do the job. Personal appearance isn't always that big a factor. However, at the same time attitudes towards personal appearance can vary wildly from company to company, it can also vary depending on the nature of the position you are applying for (i.e. whether or not you will be meeting clients).

As a long-standing extreme-metal drummer, my appearance is generally somewhat alternative/hobo-like. Heh heh.
Combat trousers/jeans, T-shirts featuring bands nobody has heard of, boots, long goatee beard, long hair and some facial piercings (no hair or piercings atm though. I look more like a deranged, big-bearded Uncle Fester nowadays!)

Despite my alternative preferences, whenever I go to job interviews I make a point of wearing an all black shirt/tie/trousers/boots combo. But I still look more than a little unconventional. Over the years I've had two interviews where I've been told that my appearance was a factor in not getting the position. But in most cases where I've failed at interview it was usually because there were better qualified and/or more experienced candidates.

On the flip side of that, every programming job I've succesfully interviewed for and accepted has been attributed to my ability to write code, my natural enthusiasm for what I do and to my generally amiable, yet self-deprecating personality. In these cases, my physical appearance has never come into the equation.

My last job had a fairly strict dress code (shirt, trousers, shoes, …

DJSAN10 commented: :) :) +0
JasonHippy 739 Practically a Master Poster

As you have Windows 7 installed on your PC, I recommend using the Windows version of unetbootin. So to get OpenSuse onto your USB drive you'll need to do the following:

  1. Boot into Windows and login to your desktop.
  2. Download and install the windows version of unetbootin
  3. Download the .iso for the latest version of OpenSuse
  4. Insert your USB drive and format it. You can do this quickly and easily in Windows by opening 'My Computer' and then right clicking on the entry for the USB drive and selecting 'Format...'. NOTE: Ensure it is formatted as FAT32
  5. Run unetbootin to install the OpenSuse .iso onto your USB drive.

NOTE: When you first run unetbootin the 'Distribution' radio button is selected; which allows you to select a version of a distribution, which it will then download. You do not want to use this option because it typically contains download links for outdated versions of the distros it supports. So you need to select the 'Disk Image' Radio button instead.

Here is a screenshot of unetbootin, taken from the unetbootin projects sourceforge page. The screenshot depicts using unetbootin to install Ubuntu 10.10 on a USB drive, using the 'Disk Image' option.

To install Suse onto a USB stick with unetbootin using the 'Disk Image' option:

  1. Select the 'Disk Image' radio button in unetbootin
  2. Select 'ISO' in the dropdown box next to the 'Disk Image' radio button
  3. Click the '...' button on the …
JasonHippy 739 Practically a Master Poster

Hey Andy.
You might want to try adding an event listener for the ENTER_FRAME event and set up a handler function to update the text box each time the event is detected.

The ENTER_FRAME event is an event which is dispatched by Flash's event dispatcher each time a new frame is drawn. So by adding an event listener and a handler, you can update the text box each time a new frame is drawn.

Here's a simple, yet complete example of what I mean (Note: This is done in AS3/Flex not the Flash IDE...I've not used the Flash IDE for years!):

package 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.TextField;
	
	/**
	 * Example using Flex SDK.
	 * Creates two text fields.
	 * Uses an event listener and a handler function to update the text-boxes
	 * with the X and Y positions of the mouse cursor.
	 */
	[SWF(backgroundColor="0xffffff", width="800", height="600", frameRate="25")]
	public class UpdateText extends Sprite 
	{
		private var text1:TextField;
		private var text2:TextField;
		
		public function UpdateText()
		{
			// Add two text fields to the stage.
			text1 = new TextField;
			addChild(text1);
			text2 = new TextField;
			text2.y = 20; // place text2 directly underneath text1
			addChild(text2);
			
			// Set up an event listener to listen for the ENTER_FRAME event.
			this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}
		
		// This is the function we specified in our event listener.
		// This will deal with updating the text boxes each time the listener
		// detects an ENTER_FRAME event 
		private function onEnterFrame(e:Event):void
		{
			text1.text = "Mouse X = " …
JasonHippy 739 Practically a Master Poster

AFAIK, on Linux .bin files are usually self-extracting files.
Things like the linux versions of the Oracle/Sun Java runtime and Flashplayer are often distributed as .bin files, which self-extract and then run an installer/script to install the program.

In order to use .bin files, you usually just need to run them. But you'll almost certainly need to make the file executable by changing its permissions before you'll be able to run it.

IMPORTANT NOTE: You should only change the .bin files permissions and run it if you are happy that it is from a trusted source and it is genuine! (a fairly basic bit of common sense, but I feel it's worth mentioning)
As long as you are happy that the file is genuine, or you're willing to take a risk, then you can proceed...

To change the permissions, you can usually do this graphically via your desktop file-manager by navigating to the files location and right clicking on it. Then select 'properties' and locate and tick a checkbox in the properties dialog to make the file executable.
Otherwise, you can do it from the command line:

chmod +x /path/to/filename.bin

where '/path/to/' is the path to your file and 'filename.bin' is the name of your .bin file

The next step is simply to run it, either by double clicking on it in your file manager, or via the command line:

/path/to/filename.bin

If changing permissions and executing the file doesn't work with your .bin file, then …

JasonHippy 739 Practically a Master Poster

If Ubuntu is installed on the logical 'D:\' volume; when you are running Ubuntu, you ARE accessing the D drive and it IS mounted. It's just not called 'D:\'

The thing to bear in mind here is that the various Linux file-systems are completely different to the NTFS/FAT based file-systems used by Windows. Also different drives/volumes in Linux are not assigned letters like in Windows. So when you are logged into Ubuntu, the root of your 'D:\' partition will be the '/' directory, this is called the root directory. All of the subdirectories off of root '/bin/', '/home/', etc are also technically all on the 'D:\' too. As I said, it's just not called 'D:/'

Linux treats pretty much everything as a file. Any devices attached to a Linux system will have a file-entry somewhere in the '/dev/' folder. To mount the 'C:\' manually, you'd have to identify which file in '/dev/' relates to your drive/volume. Typically drives/volumes are usually given names like sda1, or sdb1 in /dev/.
After identifying which of the entries relates to your 'C:\' partition, you could manually mount it. But as Ubuntu auto-mounts any attached devices/filesystems that are present, your 'C:\' should be auto-mounted anyway when you log in and should appear as an icon on the desktop.

So from Ubuntu you should easily be able to access your windows partition and manipulate the files on it.

But AFAIK, Windows cannot mount, read or write to anything other than NTFS …

JasonHippy 739 Practically a Master Poster

Declarations of for loops have three sections that are in a specific order:

for({initialiser}; {break_condition}; {increment/decrement})

But the increment and conditional sections in all of your for loops are in the wrong place. And because you're putting things in the wrong place, your loops are not doing what you're expecting them to!

In all of your for loops you are doing this:

for(int i=1; i++; i<=n) // for(init; increment; break_cond)

When you should be using:

for(int i=1; i<=n; i++) // for(init; break_cond; increment)
hqt commented: good :) +1
JasonHippy 739 Practically a Master Poster

Hey all.
Figured this might be a good place to post this.
After seeing some pics on Facebook of a recent Daniweb sponsored event; seeing all of that Daniweb swag made me wonder if Dani or one of her minions have considered setting up an online store to sell some of it? I couldn't see anything on the site about an existing store, but I'm pretty sure a lot of people from the community would part with some cash for some Daniweb branded items. (especially those in far flung corners of the world who can't make it to NY.).

As long as setting up and running the store isn't too expensive, it could provide another revenue stream while at the same time advertising the site... It was just a thought!

Is there already a store?
If not, would there be much demand for one?
What do you guys 'n gals think?

jingda commented: Nice idead +0
JasonHippy 739 Practically a Master Poster

Looking at the code you've posted (which is C rather than C++), it seems to be using a simple sockets connection to determine whether the website is up or down. The headers included in the listing that you don't have, or don't recognise are all Linux/Unix specific headers.

I'm still familiarising myself with Linux programming so I may be wrong, but I don't think anything from "sys/types.h" and "arpa/inet.h" is being used in the listing. So these headers are not required and can probably be discounted/removed.

Regarding the other Linux specific headers:
1. "unistd.h" is used for the call to close(sock); at line 50. Not sure what to suggest there for Windows. (The winsock function closesocket()?)
2. "sys/socket.h" is required in order to be able to use sockets in Linux. For windows you'll almost certainly need to use "winsock2.h".
3. "netdb.h" is required for the definitions of the addrinfo struct and the getaddrinfo() and freeaddrinfo() functions. Again, these should be implemented or at least have equivalents somewhere in the Windows Sockets API.

From what I've seen, the code you've posted should be fairly easy to port to Windows. You just need to bone up on the Windows Sockets API. It's been ages since I did anything with sockets on Windows, but MSDN documentation can be found here:
http://msdn.microsoft.com/en-us/library/ms740673%28v=VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/ms741416%28v=VS.85%29.aspx

And I assume you know what you're doing with regard to creating a .dll, so I'll leave that side of …

JasonHippy 739 Practically a Master Poster

As far as I understand it, everything is treated as a file in Unix and Linux. Even devices and running processes.

Typically, the file-system entries for all connected hardware/devices can be found in the /dev directory (and its sub-directories). If you open up a terminal and cd to /dev and then use ls -a -l , you can see which files refer to which devices.

There are two types of devices, block and char. Block devices tend to be things like RAM and hard-drives and char devices are pretty much anything else.

I don't know much more than that myself atm, so I can't really elaborate further, but I hope this helps!

rch1231 commented: Accurate and short. +8
JasonHippy 739 Practically a Master Poster

The first thing I'd say is that the static_cast is inappropriate. dynamic_cast would be more type-safe. But because CVSystemDLL derives from IVSystemDLL, you should be able to point your IVSystemDLL pointer directly at a new instance of a CVSystemDLL object with no need to cast.
I haven't had my first coffee of the day yet and i'm slightly hung over, so I'm not exactly 100% awake atm, but as long as the pointer allows you to access the derived classes implementation of the main function and not the base classes pure virtual one you should be OK. Otherwise you'd have to cast the base-pointer back to it's correct derived type using a dynamic_cast before calling main. As I said I'm not quite alive yet, so I could be wrong, but that's my two pence!

JasonHippy 739 Practically a Master Poster

Generally speaking, when you download and use 3rd party libraries you just need to set the compiler up to look for additional headers in the library's 'include' directory, and you point the linker to it's 'lib' directory to allow it to link your program using the provided .lib's/.dll's or .so's.

Some libraries contain pre-compiled binaries in their 'lib' directory. Others may require you to build them from source before you can use them. Typically the owners/creators of any given library will provide instructions on this.

In VS, you can set up the search-paths for directories containing additional header and library files on a per-project basis in the project settings.
e.g.
Select 'Project->Properties' in the main menu to bring up the project properties page.
Under 'configuration properties' select the 'C/C++->General' tab and select the 'Additional include directories' field. Then click on the '...' icon to open another window which will allow you to add the paths to the 'include' directory of your 3rd party library to a list. You can also alter the include order by moving entries up or down the list.

Then under the 'Linker->General' tab you can do a similar thing with the 'Additional Library Directories' item and add paths to the 'lib' directories of any 3rd party libraries you want to use.

Alternatively, you can set up the search paths as global paths in 'Tools->Options' under the 'Projects and solutions->VC++ Directories' item:
Select the 'show directories for' drop down …

sergent commented: .. +4
kvprajapati commented: Good post. +15
JasonHippy 739 Practically a Master Poster

You said you had the language pack, but I wonder if there are some additional libraries that you still need. You could use apt-cache search korean to see what other libraries are available. You might want to try using 'hangul' as a search term too. Install any related libraries you don't already have using the apt-get install command. I think some of the multi-byte languages require input method libraries, so installing any of those that appear in your korean/hangul searches may help. The only other thing is a font, but I would have thought that would be in the language pack.

JasonHippy 739 Practically a Master Poster

Assuming you're using Gnome:
1. Go to 'System->Preferences->Keyboard'
This will open the keyboard preferences window
2. Click on the Layouts tab
3. In the layouts tab select the 'Add' button.
This will pop up a dialog where you can set up the keyboard layout for whatever country you like. In this case, you want Korean!

Once you've done that, you simply set which of your keyboard layouts you want to use. I think there's a 'keyboard switcher' panel widget which you can put into a desktop panel and use to instantly switch between any keyboard layouts that you have set up.

If you're using KDE or any other desktop/WM, there will be a similar tool somewhere in the options to allow you to set your keyboard preferences.

JasonHippy 739 Practically a Master Poster

If possible, can you give a short explanation on how does this linux command

sudo find . | xargs grep -i 'NameOfFunction'

work? Thanks.

It simply uses the pipe operator and xargs to pass output from the find command into the grep command:

1. sudo runs the command as root (after prompting you for a password) allowing the find command to list system files owned by root and files owned by other users

2. find . will cause the find command to list all files it finds starting from the current directory

3. The pipe operator "|" passes/redirects the output from the find command to grep via the xargs command.

4. grep -i 'matrixCal' will search the listed files and output any which contain the text 'matrixCal'.
The "-i" switch causes grep to ignore the case of the search string.

That's basically how Nonshatters suggested command works. But running that will soon fill your terminal with results and error messages from grep and will take a long time to run as it will search every file in the file-system.

One way of speeding up searches is to use a built-in update script to update the database that find uses. Running this from time to time can aid in speedier searches.
I tend to run this at least once a month, if not once a week.
I usually do it manually, but you could set up a cron job to run it automatically if …

JasonHippy 739 Practically a Master Poster

If it's ODBC you're using, then it sounds like you need to set up a data source in Windows.

To do this you need to run the administrative tools. The location of this varies from version to version of Windows, but I think if you open up control panel, there should be a link to the administrative tools which should bring up an explorer window with shortcuts to various Windows administration programs.

From the admin tools window you need to run the ODBC Data source administrator tool which is listed as 'Data Sources (ODBC)'

From there you need to add a new data source and follow the steps in the wizard to set up the connection to the SQL server database.

Before you do that, going back to your code, in the string returned by your getDbConnString function, uid is the user ID (set to 'test') for the user of the database, pwd is the users password (also set to 'test') and dsn is the data-source name (set to 'dnsname').

Bearing that in mind, when you set up your ODBC connection in the ODBC Data source administrator, the first thing it asks you for is a name to use to refer to the data source. If you use 'dnsname' as the name for the connection then your program should work.

Basically, the name of the ODBC connection needs to match whatever you've put in the 'dsn=...' part of the connection string.
So if …

JasonHippy 739 Practically a Master Poster

One thing you need to bear in mind is that all of the commands available in BASH (and the various other shells in Linux) are programs or scripts that reside in various system folders specified in the $PATH environment variable.

The /bin/ directory typically contains programs/commands that are ran at boot-time.
The /usr/bin/ directory is the main system folder for user-space programs/commands.

Whenever you type a command in Bash you are simply running one or more of these programs and passing various parameters. So for example, the command ls -l calls the system program 'ls' (which lists the contents of a directory) and passes the parameter '-l' which gives more detailed information about the listed files.

There are lots of different ways of creating your own custom commands in Linux. And how you do it depends on how far you want to take things!

Creating your own commands could be as simple as using the pipe or redirection operators to string together several calls to various 'simple' system commands/programs(using the output from one command as inputs to others, or to redirect output from a program into a file).
Take a look at this link:
http://www.tuxfiles.org/linuxhelp/iodirection.html

Or you could write a script to perform a specific task. This could be done by writing a shell-script or by using some other scripting language (perl, python, lua etc).
Here's a link to one of the many shell-scripting tutorials out there:
http://www.freeos.com/guides/lsst/

JasonHippy 739 Practically a Master Poster

I think it's because the calling conventions and object formats in C and C++ are slightly different. So the object file created by gcc is not compatible with the object file created by g++. Possibly something to do with the function name mangling or some-such. I don't have a massive amount of knowledge in this area, but it's certainly some kind of compatibility thing!

So because of the incompatible object formats, when you try to link the two objects to make your executable; I think g++ is unable to resolve the call to para_prep and is showing an error message.

So I guess you have two options here:
1. If mainlib really has to be compiled using gcc, then I suppose you could make mainlib a shared object (.so) and compile/link it with gcc and then use the shared object in your program (just like a .dll in windows programs). In which case you'll need to read up on creating .so's in C and how to use C-based .so's in a C++ program.

OR more simply:

2. You could use g++ to compile and link all three files!
Just because mainlib is written in C doesn't mean you can't use g++ to compile it. After all, any valid C program can also be considered to be a valid C++ program, so g++ should be able to handle it!

So perhaps try this:
g++ -c main.cpp
g++ -c mainlib.c
g++ -o …

JasonHippy 739 Practically a Master Poster

Part of the problem here is you are using an unsafe C-style cast. Also because you have a virtual function in your base class you're dealing with polymorphism.
When attempting to cast polymorphic types, you need to enable RTTI (Run Time Type Information) in your project and use the dynamic_cast operator to cast pointers between polymorphic types in a safe manner.

How you enable RTTI will vary depending on the compiler/IDE you're using.
Typically in VS you go to your project properties and in the 'C/C++ -> language settings' tab you set the 'Enable Run-Time Type Info' item to Yes.
Or you can go to the 'C/C++ -> Command line' tab and add the /GR switch to the additional options. If you're using another Compiler/IDE, you may have to consult your manual!

The dynamic_cast operator attempts to cast one type to another, but if the cast fails, it returns a null pointer. Which is far safer than using the C-style cast which will cast the pointer/object regardless of whether it is valid or not!

Also, with your classes you need to take note that an instance of a Circle can be considered to be a valid instance of a Shape, so casting from a Circle pointer to a Shape pointer should work, but the converse is not necessarily true. A Shape pointer doesn't necessarily point to a Circle, it could be pointing to a Square, or any other Shape derived class. It could even …

jonsca commented: Nice post. +14
JasonHippy 739 Practically a Master Poster

Well, if you plan to write programs for Linux the choice is yours. You can use virtually any programming language, be it a popular modern language or a really old obscure one.

The real hard-core *nix programmers use a text editor like vi, scite or emacs to write their source-files and use the command-line to compile/build their programs. But there are IDE's available for most languages too, so you don't have to work with the command line if you don't want to!

If you're used to using an IDE like Visual studio. Then there are things like Monodevelop for C#, Code::Blocks for C/C++, Eclipse/Netbeans for Java, Idle for Python, Gambas for BASIC etc.

Most of the IDE's that I've seen in *nix are fully featured, generally well documented and pretty easy/intuitive to use. And there are plenty of learning resources posted all over the web for most languages too!

With regards to which languages are typically used for what in Linux:
Much of the underlying system is written in C and assembly (e.g. the Kernel and the core Linux OS components/tools). So if you plan to do low-level OS stuff (kernel modules, drivers etc) then C is a must and some knowledge of assembly may help too!
nasm is the main compiler used for assembly AFAIK.

The core of the Gnome desktop environment is C based.
The core of the KDE desktop environment is C++ based.

User-space/desktop applications can be programmed …

n_e commented: Good detailed answer +2
JasonHippy 739 Practically a Master Poster

As sergent and WaltP have pointed out:
Using standard C/C++ as far as possible is the best way of ensuring code portability.

At the risk of going off topic, using other cross-platform libraries/frameworks (boost, wxWidgets, GTK, QT etc.) can also make it easier to create cross-platform applications without using non-portable code (Obviously, this would only work if the libraries you're using are available on all platforms you intend to target!)

But in cases where very specific functionality is required, you may also have to do a bit of conditional compilation.
With conditional compilation you can enclose non-portable code with conditional pre-processor statements, so non-portable/platform-specific code is only compiled when the code is compiled on a particular operating system and/or using a particular compiler.

The only downside to conditional compilation is it can make the code a little messy and hard to read/understand. Especially if you plan to support a lot of different OS'es and compilers. It can also become a bit of a maintenance burden!


e.g. conditional compilation dependent on the operating system:

// use preprocessor to determine the platform:
#if defined(unix) || defined(__unix__) || defined(__unix)
# define PREDEF_PLATFORM_UNIX
#elif defined(_WIN32)
# define PREDEF_PLATFORM_WINDOWS
#endif

// standard C++ headers (should be cross-platform)
#include <iostream>
#include <string>
// ...
// Other standard headers here...
// ...

// platform dependant #includes
#if defined PREDEF_PLATFORM_UNIX
#include <unistd.h>
// ... 
// other Unix/linux specific headers
// ...
#elif defined PREDEF_PLATFORM_WINDOWS
#include <windows.h>
// ...
// …
JasonHippy 739 Practically a Master Poster

@OP:
In answer to your question about vectors, a vector of std::strings can hold any number of valid std::string objects. Whether or not they contain whitespace is completely irrelevant. As long as a string object is valid, the vector should be able to contain it!

Obviously it seems me that you think your vector is causing your problem, somehow only storing only the first word of each string your user enters. But in actual fact, you're almost certainly using an inappropriate method/function to get your string input from the user in the first place.

How strings are retrieved from the input stream and stored will depend on which function you use to get them from the user.

From what I've seen I'm assuming you're probably using std::cin or something similar which copies everything up to the first whitespace character, or the first return character (whichever is first) into the string object.
e.g.

std::string str;
std::cout << "enter a string: ";
std::cin >> str;
std::cout << "You entered: " << str << std::endl;

Using the above code snippet, if you entered 'super mario bros', because cin only gets everything up to the first whitespace character, the string will only contain 'super'. So when you subsequently push your string into the vector, the only thing that goes into the vector is the string 'super'.

In other words, if you are using std::cin to get strings in your program, then you are getting exactly what you …

Saith commented: Very nice explanation! It does some nice critical thinking of what you could possibly assume what the OP was requesting and revealing the steps to fix the entire logical problem instead of a simple code snippet. +2 if possible. +1
jonsca commented: Agreed. Good to see you posting again Jas! +7
JasonHippy 739 Practically a Master Poster

If there's no graphic interface, you may have to manually mount your usb drive (unless your OS happens to auto-mount drives).

NOTES: Before we start, This is completely off the top of my head, I've not got a *nix box in front of me to test any of this atm, but it should work. Apologies if there are any errors though! Also you should be aware that I tend to use debian based distros, so I've included use of sudo to get root access in the following guide. You'll need to substitute sudo for su, or whatever your distro uses to get root access.

Anyway, moving onward!
To manually mount, you'll need to do the following:

1. After plugging a USB drive into your machine, you need to use the lsusb command to see what devices are connected via USB and search the output for anything that refers to your USB stick.

If you can see something which refers to your USB stick (manufacturer, capacity etc.), you'll know for certain that your system has recognised the device and you can continue on to mount it.
But if you don't see anything, there's no point attempting to mount the device, as the OS has not detected/recognised it!


2. Assuming you found your device, next you'll need to get a list of connected drives using:

dmesg | grep -i "SCSI device"

Again take a look in the output for something that refers to …

alaa sam commented: thanks alot for your help +0
JasonHippy 739 Practically a Master Poster

If it's not available in the Software Centre, or via Synaptic package manager; a stable version of Chrome is available directly from google as a .deb package. You can simply download the package and install it yourself!

Here's the link:
https://encrypted.google.com/chrome?platform=linux&hl=en&lr=all

Personally I'd check the software centre or synaptic first, I think the Ubuntu version of Chrome is called Chromium, so you might want to try searching for that first. If it's not there, then use the link above and you can download and install it yourself!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Any chance you could clarify this a bit further? I don't really understand what you're trying to achieve here!

Do you mean as soon as the swf has loaded, you want it to take a screenshot of the entire web-page??

If so, it sounds a bit unlikely to me as the swf will not be able to see anything external to itself. So it wouldn't be possible to take a screenshot of the entire web-page directly from Flash/AS3 (at least as far as I'm aware!)

You MAY be able to connect your swf to an external server-side script (javascript/php) which could retrieve the HTML for the page and generate an image of it. But again, I'm really not sure!

If it is possible, it would probably require quite a lot of work and resources to set up. What do you intend to do with the screenshot after you've got it?

theighost commented: Clear response, good suggestion +0
JasonHippy 739 Practically a Master Poster

On top of the comments made by Moschops, it seems blatantly obvious that you haven't got a file called countertype.h, you've put all of the code for your class into a file called countertype.cpp.
So you need to either rename countertype.cpp to countertype.h, or separate the code so that the declaration of the class is in a header file and the definition/implementation of your class is in a .cpp file with the same name.

The 'unexpected end of file' error is because you've forgotten to include a semicolon at the end of your class declaration.
e.g.

class myclass
{
...
}; // <<<---- class declarations end with a semicolon!
Moschops commented: This is a righteous post from the hippy community :) +3
JasonHippy 739 Practically a Master Poster

I'm not sure you've posted in the correct forum, I think you want the shell scripting forum!

Anyway, I think what you're after is this:

%USERPROFILE%\Desktop

So if you wanted to navigate into the current users Desktop folder in your .bat file, then you would use:

cd %USERPROFILE%\Desktop

Likewise, if you want to pass the path to the Desktop folder as a parameter to the executable you're calling, then in your batch file you could use:

program.exe %USERPROFILE%\Desktop

Or if the program you're calling requires a switch to be specified before the path, then you'll need to do something like this:

program.exe -X %USERPROFILE%\Desktop

where -X is whatever switch you might need to specify before passing the path.

Ancient Dragon commented: So I used the correct environment variable afterall :) +35
MasterGberry commented: Perfect explanation :) +0
JasonHippy 739 Practically a Master Poster

For starters, that is a C source file you are editing, NOT a C++ source file (so you've posted in the wrong sub-forum!).

As this is a C project you are editing, it is reasonable to assume that any project files or makefiles for the project will have the strict C mode flag set for any C++ compilers, so the code is parsed and compiled as C rather than C++. In strict C mode (as per standard C syntax) your compiler expects all variable declarations/definitions to be at the top of a block.
So the problem is due to where you are declaring and using 'r' in the middle of a block of code. What you need to do is declare r at the top of the block (the top of the function) and then use it later on in the function!

Try this:

// XorLib 1.0.0.0
// Copyright [c] 2009-2010 Shadowscape Studios. All Rights Reserved.

#define export __declspec (dllexport)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

long filesize(FILE *f)
{
	long fs;
	fseek(f,0L,SEEK_END);
	fs = ftell(f);
	fseek(f,0L,SEEK_SET);
	return fs;
}

export double crypt(char *rn, char *wn, char *sb, double ss)
{
	FILE *rf, *wf;
	unsigned char fb[BUFSIZ];
	unsigned int bp, sp = 0;
	size_t bs;
	if ((rf = fopen(rn,"rb")) == NULL) { return 0; }
	if ((wf = fopen(wn,"wb")) == NULL) { return 0; }
	while ((bs = fread(fb, 1, BUFSIZ, rf)) != 0)
	{
		for ( bp = 0; bp < bs; ++bp )
		{ …
shadowscape commented: thanks alot for all your help, i can tell you how much that means to me +1
JasonHippy 739 Practically a Master Poster

I understand that sounds wonderful. I have to ask about one detail though of how to set up this parameter. Do I need to first connect and then check this in the if statment or will I just write the if statement.

For example do I need the first line here ?

sftp->Connect(hostname, port);

if (sftp->Connect(hostname, port)) {
  //perform your transfer if true/non-zero
} else {
  //error handling if false or zero
}

{facepalm}

No, you don't need to call it twice! You just call it once inside the if statement as recommended by myself and Fbody!

Basically the Connect function is called inside the if statement. The if statement then evaluates the return value from the Connect call.
So if the Connect function returns true (or non zero), then the code under the if statement is executed. Otherwise if Connect returns false (or 0) then the code under the else is used!

I hope that clears things up for you!

JasonHippy 739 Practically a Master Poster

Have you tried this??

if(sftp->Connect(hostname, port))
{
	// do something
}
else
{
	// Whoops sftp->Connect() failed!!
}

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Someone left a comment on one of my posts similar to, "Linux won't be popular on the Desktop until it runs Windows applications." To which I silently responded, "Huh? and, "You've got to be kidding me." We have WINE for running Windows applications and it works reasonably well for those who care to spend the time to work through any problems with it. I don't think the Linux Community needs to spend time on such an undertaking. Is anyone asking Apple to run Windows applications so that it will gain popularity? No? Then, why should Linux? If you want to run Windows applications, run them on Windows.

Linux is Linux. Mac OS is Mac OS. And, Windows is Windows.

Why does anyone want or need any crossover?

If application vendors want to create applications that run on Linux, that's great. I'm behind that 100 percent. If Intuit, for example, wants to create QuickBooks that runs on Linux, I'd buy it. If Adobe created Photoshop for Linux, they'd have an audience. And, if Microsoft created Microsoft Office for Linux, it would sell too. After all, the first operating system that MS Office ran on was the Mac OS.

And, why would you want to run Windows applications when we have OpenOffice.org, KOffice, GIMP and many others that are actually better than their Windows counterparts? They're so good that all three of the ones I mentioned …

JasonHippy 739 Practically a Master Poster

Well, this topic isn't particularly C++ related, but....

When you say bootable, do you mean that you simply want it to auto-run from the USB stick when the USB stick is inserted?

Or do you mean that you want the computer to boot from USB into your product when the computer is turned on?


If it's just a case of auto-running the app when the USB stick plugged in, then you just need to create an autorun.inf script file which will run your application when the USB device is inserted. But you should note that for security reasons, a lot of savvy Windows users will have auto-play disabled. So this could prove more or less pointless as windows users with autoplay disabled would have to manually start your program themselves.

But if you want to boot into your app from startup via USB; As far as I'm aware, you'll need to create and include your own minimalist version of an OS on the USB drive to run the app in.

In other words, your minimal OS boots from the USB drive and then runs your application.

I don't think it's possible to do this with Windows, for starters you'd have to have to install a heavily cut-down and customised version of windows on each USB stick you distribute which would prove expensive for you what with the cost of Windows licences. Secondly, I'm not sure whether Microsoft would allow this kind of …

JasonHippy 739 Practically a Master Poster

Personally I find Eclipse a bit slow and bloated on *nix. But that might be down to my crappy hardware more than anything else!

My IDE of choice for C++ on *nix is Code::Blocks. It's relatively small, it's fast, it looks and behaves similarly to Visual Studio and it integrates and works really well with the native *nix compilers (gcc, g++, nasm etc). Code::Blocks also ships with C/C++ project templates for several popular graphics/GUI libraries (wxWidgets, QT, OpenGL, OGRE, GTK etc), which can help to get new projects up and running quickly with a mininmum of fuss.

Incidentally, if you're interested in developing applications using C++ and wxWidgets, then the 'codeblocks-contrib' package is another must-have for Code::Blocks as it includes the wxSmith plugin, which can aid rapid application development with wxWidgets.

The wxSmith plugin extends Code::Blocks allowing you to visually/graphically place wxWidget controls on dialogs and windows. The plugin then auto-generates C++ code in your project in a very similar way to Visual Studio. If you've ever done any MFC development in Visual Studio on Windows; you'll find that using wxSmith with Code::Blocks is very similar!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

As iamthwee has said, you need to install g++ to be able to compile C++ on *nix.

But if it's a C++ IDE you're after, then Code::Blocks is probably the best on *nix. Anjuta is another of the commonly used *nix C++ IDE's.

In both cases you'll still need to ensure that you've got g++ installed as both ide's are basically graphical frontends for gcc/g++!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Hmm, that's a very interesting question...
I tend to listen to a lot of different music at work and at home, but my choices usually depend on my mood and my activity rather than any specific language I might be using.

For example, if I'm debugging code, reviewing code, or doing anything that requires intense concentration; I'll usually throw on something more atmospheric. e.g. light classical, folk, acoustic, light jazz, ambient, industrial, noise or drone. But the exact selection will depend on my mood, so it could be anything from Norah Jones to Merzbow.

However, if I'm banging out code, then it'll be something with a bit more energy. Again this would depend on my mood, but I usually select something that I can rock out to when code-jamming! So it could be virtually anything from rock, metal, thrash, death/black metal and grindcore to dance, glitch, drum & bass, electro and industrial. I usually choose something technical or unusual (Tool, Meshuggah, Venetian Snares, Frontline Assembly etc.), but sometimes you can't beat something simple that rocks out in straight 4/4!

So going back to the original question, no I don't listen to a particular genre when programming in a particular language. But if I had to equate a programming language to a specific music genre then I guess this would be my list:
Assembly/Machine code:
Industrial/Electro Pop/New Wave (think Kraftwerk, Throbbing Gristle or Devo), full-fat geek!

C++:
Math Metal (Meshuggah, Dillinger Escape Plan, …

JasonHippy 739 Practically a Master Poster

Yes, the two pages I linked to give details of the syntax, but if you read both of the pages in their entirety, they go on to explain some of the mechanics of the functions. I'll admit they don't go into detail about any differences between using them in user-mode or kernel mode, but it's a start at least!

However, there is nothing to stop you from browsing the Linux source code and taking a look at the read and write functions yourself. (Linux is open-source after all!). If you take a look at the sources, you should be able to work out what's going on for yourself! The site that Salem linked to would help with this.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Whilst I agree that Ubuntu is a great Linux distro to get started with; Looking at the original post, the title mentions that the PC in question runs Windows ME, which implies to me that the hardware will be quite old. So perhaps a more lightweight distro would be in order.

I'd wager that Ubuntu would most likely be a bit too bloated and heavyweight for a machine of that age. However Xubuntu might be worth a try, dependant on the amount of RAM the PC has. But you'd probably have to use the alternate install CD rather than the liveCD..I think the liveCD of Xubuntu would still be a bit too heavyweight!

Failing that, perhaps WattOS (Ubuntu-based lightweight distro) or Zeven OS (a little known Xubuntu-based lightweight distro).

Otherwise there are plenty of other distros available like Unity, Slitaz, Vector, Zenwalk, Antix, Tiny ME, Puppy and DSL which are all geared towards running on older hardware. But like I said, it does depend on the exact specs of the machine.

There are shed-loads of different Linux distros out there and they're all free. So as long as you have a bit of free-time and a decent internet connection you can download several different versions of Linux per day. My advice is to take some time and shop around a bit. Take a look at distrowatch.com, google/search for lightweight linux distros, download some LiveCD's and find the distro that works best for you and …

JasonHippy 739 Practically a Master Poster

From what I've seen there are two main camps who are opposed to Mono. There are the Microsoft haters, many of whom simply dislike Mono because it implements C# and emulates the .NET runtime, which are both 'evil' Microsoft technologies. Others see the Mono runtime as an unnecessary, unwelcome and bloated addition to their system. There are other arguments used by various other groups who are anti-Mono, but those are probably the top two from the Microsoft haters!

Then there are all of the 'Windows only' Microsoft lovers/snobs who see Mono as an inferior version of .NET. The way they see it, Microsoft will always be one step ahead of the Mono project. Microsoft will introduce new features into .NET and the Mono project will follow on behind them like lost, scavenging dogs.

But this viewpoint doesn't hold a lot of water IMHO. Even if Microsoft does go ahead and add lots of new features to .NET, Mono doesn't necessarily need to try to keep up with them. What they've already implemented of .NET will do the job sufficiently. Mono already allows users of different platforms to be able to compile C# code on their native platform. (Which is the main thing)

All it will mean is that Mono applications would not have the most cutting edge features of the very latest version of .NET. But the core .NET features are still there and are enough to allow many developers to develop robust applications with.

As …

JasonHippy 739 Practically a Master Poster

It seems to me that the only reason these corporations are starting to persecute open source projects is because they represent a growing threat to their greedy profit margins!

This quote sums things up nicely (not sure who originally said it!):
Nothing is done for the common good where there is money to be made.

In recent years there has been a gradual swing towards using open source software. Personally I don't know a single person who owns a PC who doesn't use software from at least one open-source project. Obviously the corporations are waking up to that fact and now they are trying to do something draconian about it in order to protect their profits.

It's not like they aren't making enough money already is it? It's just playground bullying tactics taken to the nth degree. Are they really losing out on that much money due to open-source? If so, perhaps we aught to squeeze them a bit more by encouraging more people to switch to free/open source software.

The corporations know full well that even if they don't have a valid/solid case against an open-source project, the very threat of legal action would be enough to cause many projects to simply fold as I suspect most open source projects couldn't afford to pay the costs for legal help during any case against them. So in many cases fighting against such a lawsuit would be completely infeasible, probably causing them to settle out of …

rich3800 commented: To make a REASONABLE profit is the goal. +0
JasonHippy 739 Practically a Master Poster

Well, have you tried google?? heh heh! :P

And I'm not just being gratuitously facetious here, there is a serious point I'm trying to make.

For example:
After reading your post I really didn't know what CAN was, so I did a bit of googling of my own because I'm kinda curious like that.

According to wikipedia:

"Controller–area network (CAN or CAN-bus) is a vehicle bus standard designed to allow microcontrollers and devices to communicate with each other within a vehicle without a host computer."

(see http://en.wikipedia.org/wiki/Controller_area_network)

Hopefully this is the CAN you're referring to, it's the closest thing I could find!

Next I tried googling NCTYPE_UINT8. About half-way down the page I found a couple of .pdf manuals for the National Instruments CAN API which both appear to relate to the CAN bus standard mentioned above, so it looks like I'm on the right track!

The manual details all of the types used by the API and assuming this is the API you're using (I think the chances are pretty good!), it would seem that NCTYPE_UINT8 has been defined as unsigned char.
(see www.ni.com/pdf/manuals/370289c.pdf and www.ni.com/pdf/manuals/321369a.pdf to get the manuals)

So, given that information I guess you'd need to convert the string from your text box into a c-style string (char * or char array[]) and then perhaps convert (or typecast) and copy that into an unsigned char array.

And I think that's …

jonsca commented: All good points and well researched! +4
JasonHippy 739 Practically a Master Poster

I prefer VLC and it's in the repos. This isn't Windows so I don't suggest downloading unknown apps from the Internet. Mplayer is good but you have to install MS codecs. VLC will play just about anything.

I second that motion! VLC is my media player of choice on all platforms!

JasonHippy 739 Practically a Master Poster

Take a look at these two articles which both provide details about the available programs/libraries for detecting memory leaks in *nix:
http://www.linuxjournal.com/article/6059
http://www.linuxjournal.com/article/6556

Other than Valgrind, it lists several tools/libraries.....

For programs compiled in C:
mtrace
memwatch
dmalloc

For C++ programs:
dmalloc
ccmalloc
NJAMD
YAMD
mpatrol
Insure++

Valgrind seems to work fine for me (EDIT: But then I'm not using it for embedded stuff!). As a consequence, I've not really used any of the others, so I can't make any solid recommendations.

I guess your best course of action would be to read the articles and try a few of the listed programs/libraries out and see what works best for you!

Cheers for now,
Jas.

Salem commented: Nice looking list - thanks +20
JasonHippy 739 Practically a Master Poster

Perfect Dark! That game was ace!
Goldeneye was another great fps on the N64.
I loved those two games.

But I think my favourite game of all time has to be Elite, which I remember playing on the old BBC's at primary school. I also had it on my Amstrad CPC.

But the ultimate version of the game for me was Frontier:Elite2 on the Amiga....Me and my nerd friends probably spent years of our youth on that game.... Love it!

I recently discovered Oolite, an cross-platform open-source clone of Elite. Pretty good, but I still think I prefer Frontier:Elite 2 on the Amiga.

Salem commented: Right on, commander! +0
JasonHippy 739 Practically a Master Poster

Have you tried this?? heh heh! ;)

If you had you would have found this little gem, which tells you everything you need to know! Doesn't get much simpler than that does it??

Cheers for now,
Jas.

Salem commented: Easy money :) +20
JasonHippy 739 Practically a Master Poster

P.S. There's also the /usr/share/app-install/desktop/ directory which also contains .desktop files for applications and the /usr/share/app-install/icons/ directory which contains icons for installed applications.

JasonHippy 739 Practically a Master Poster

OK hopefully this will clear up some of your questions:

The linux executable format
Most binary executable programs in Linux do not have an extension like in Windows (which use the .exe extension).
For example, the 3D program Blender, in windows the executable is called 'blender.exe'. In *nix it's just called 'blender' (no file extension)

The program launchers (I guess these are more or less equivalent to a program shortcut in windows) use the .desktop extension and are basically XML files.

File-system/paths
Regarding the Linux filesystem, the '/' at the start of a path indicates the root/top level of the file-system. It doesn't necessarily refer to any single drive per se.

So in a shell if I typed the following path:

cd /

it would take me to the root of the filesystem. Likewise:

cd /media/

Would take me to the media directory, which is off the root of the file-system. Incidentally, the media directory is where any removable USB storage devices will be listed.

Speaking of which, if we had an 8GB USB stick plugged into our PC with the volume label JAS8GB; to access it from the command line in windows you'd navigate to whatever drive letter it was assigned to:

cd J:\

(or K:\ or whatever!).

To access the device from *nix, as long as the device was mounted (which Ubuntu/Gnome seems to do automatically on insertion of USB drives), you'd need to navigate to:

/media/JAS8GB/

More on …

sneaker commented: good post :) +1