JasonHippy 739 Practically a Master Poster

According to the Adobe website, the latest version of Adobe Reader available for Linux is 9.5.4.
If you go to http://get.adobe.com/uk/reader/otherversions/ and fill out the download form (select OS, language and version), the only downloads it lists for Linux are several versions of 9.5.4 in different package formats: .bin, .deb, .rpm, .tar.bz2.

So the version you installed via the Canonical partner repo (9.5.4) IS the latest version available for Linux.

If you are worried that Adobe Reader 9.5.4 is out of date or vulnerable to malicious exploits etc, you could always use one of the many other pdf viewers available for Linux instead: Okular, Evince, epdfview etc. And if you want to edit pdf's there are programs like pdfedit or libreoffice available that can do this too. All of the programs mentioned should be available in the repos of all Debian derived distros, so they should just be an apt-get install away. :)
Hope this is of some help to you!

JasonHippy 739 Practically a Master Poster

Yes. You reset the value of i, but the value of sum is not being reset.

Once again, put the code for the perfect number and prime number tests into separate functions and lose all of the global variables. You don't need global variables in this program. Declare them where they are needed!

For example, your perfect number code can be refactored into a separate function which takes an int as a parameter and returns a bool to indicate whether a number is perfect or not.
e.g.

///////////////////////////////////////////////////////////////
/// Test whether a number is perfect
///////////////////////////////////////////////////////////////
/// \param <num> number to test
/// \return <bool> true=perfect, false=not perfect
///////////////////////////////////////////////////////////////
bool IsPerfect(int num)
{
    int i=1;
    int sum=0;
    while(i<num)
    {
        if(num%i==0)
            sum+=i;
        ++i;
    }
    return num==sum; // returns true if sum and num are the same, else returns false;
}

Or perhaps using a for loop:

///////////////////////////////////////////////////////////////
/// Test whether a number is perfect
///////////////////////////////////////////////////////////////
/// \param <num> number to test
/// \return <bool> true=perfect, false=not perfect
///////////////////////////////////////////////////////////////
bool IsPerfect(int num)
{
    int sum=0;
    for(int i=1; i<num; ++i)
        if(num%i==0)
            sum+=i;

    return num==sum; // returns true if sum and num are the same, else returns false;
}

If you look at the above snippets, the code for your perfect number test has been refactored into a function. The variables i and sum, which were global in your original code are now local to the function, so the global definitions can be removed because they simply aren't needed!

JasonHippy 739 Practically a Master Poster

You have two options here:
1. Move the code for the two functions above main, so they are defined before main
OR:
2. Create two function prototypes for the functions before main
e.g.

float ctof(float d);
float ftoc(float f);

Also you appear to be missing an opening brace '{' after main() and according to the C++ standard, the signature of main should be int main() not void main()

Another thing:
Take note that the entire user input section of your code is wrong and will not do what you are hoping to do! For starters n is never initialised, or set to anything. So your switch statement will most likely only ever use the default case and the two values entered for f and c will never be used by the program.

For the user input section of your code, I'm guessing what you need to do is ask the user for a value, then ask whether they want to convert from celsius to farenheit, or farenheit to celcius. Or perhaps you need to ask them to enter the type of conversion they want to do and then ask for the value. But what you have at the moment does neither of those things! You need to go back to the drawing board and rethink your solution to the problem a little!

:edit:
Beaten to the punch by Banfa! :)

JasonHippy 739 Practically a Master Poster

It was definitely C code I posted, not C++. And I didn't mention anything about errors, I didn't compile anything, I just made a few code suggestions. ;)

However, it's been a long time since I used C regularly and I think perhaps the standards may have changed from when I originally learnt C back in the mid 90's (on an outdated version of Borlands compiler!)

Rightly or wrongly, I was taught to always cast the void* returned to the required type when using malloc and calloc. Although....Thinking back, I think it might have been an early version of Turbo C++ that we were using as a compiler. So if what you say is true, that could go some way towards explaining why we were told to cast... Hmmm, it was a long time ago though! :/ Was it Turbo C? or Turbo C++? I can't remember!

Now I'm questioning everything I've ever been taught! Heh heh! XD
OK, thanks for that Banfa, I'll bear that in mind!

JasonHippy 739 Practically a Master Poster

@Hajkmusic:
I'd recommend breaking your program down into separate functions, making it more modular and easier for you to test and debug. The main() function should control the main program loop and user input, then you should perhaps have two bool functions to test for prime and perfect numbers. You can call these functions from main to test the numbers entered by the user.
e.g.

bool IsPrime(int num);
bool IsPerfect(int num);

I won't write the functions for you, but I'm sure you can manage to work it out from the two prototypes listed above. There's not much more involved than moving some existing code out of main and into the bodies of the functions! ;)

Regarding problem 3, the problem with your perfect number test:
Referring to your original code, the global variables 'i' and 'sum' are the cause of the problem.

'i' and 'sum' are given their initial values at their point of declaration (as globals, outside of main). Then, the first time through the main program loop, when you perform your first perfect number test, their values are modified. But their values are not reset/reinitialised afterwards. So because they are global rather than local; they hold their previous values the next time through the loop. So the next time you go through the main loop and you enter another number, the perfect number test will not give the results you expect because 'i' and 'sum' have not been reinitialised, they still hold their …

JasonHippy 739 Practically a Master Poster

I'm not sure why you'd want to have duplicate user IDs offhand, but it is possible:
Using the -o option with commands like useradd, adduser and usermod will allow you to use duplicate/non-unique UID's.

Take a look at the documentation for them online: useradd, adduser and usermod.
Or take a look at the man pages and info pages for them on your own Linux system!

JasonHippy 739 Practically a Master Poster

You're doing your memory allocation completely incorrectly. You need to allocate a block of memory for n instances of the laptimes structure. So perhaps declare two pointers to laptimes at the top of main:

int n, index;
laptimes* lapdata=0;
laptimes* competitor=0;

The first pointer (lapdata) will be assigned to point to the block of memory allocated to hold the lap times for all competitors. The second pointer (competitor) will be used to iterate through the block of memory to access each individual competitors times.

After the user has entered the number of competitors (n), you can allocate the memory for the lapdata like this:

lapdata = (laptimes*) calloc(n, sizeof(laptimes));

This will allocate space for n instances of the laptimes struct and assign lapdata to point to the block of memory that was allocated.
NOTE: calloc returns a void pointer (void*) which has to be cast to a pointer of the appropriate type - in this case we need to cast it to a laptimes pointer (laptimes*)

Next you need to ensure that the lapdata pointer is valid (i.e. not NULL). As long as lapdata is valid, set the pointer called competitor to point to lapdata (making it point to the first competitors data) before using a loop to allow the user to enter each competitors laptimes.

if(lapdata)
{
    /* set competitor to point to first competitors times*/
    competitor = lapdata;

    /* fill lapdata with each competitors times */
    for(index=0; index<n; ++index, ++competitor)
    {
        /* …
JasonHippy 739 Practically a Master Poster

Slow down chap, breathe in! Heh heh.
Because all of your posts are related; rather than creating four separate threads, you could have created one thread and asked all of your questions together in the one place!

Also, in order for anybody to help diagnose your problem with any degree of accuracy, we'll need some more information from you. All we've got so far from four separate threads is very vague information about a system that won't boot with some equally vague questions.

To allow us to help you more effectively we'll need some more solid details like:
What distro are you running and which version?
What are the specs of the machine?
What version of grub are you using?
What are the exact problems you are experiencing?
e.g.
- How far does the boot process go before it fails?
- Are you seeing any error messages from the system during boot?
- Did the problem start after any significant changes, updates or upgrades to hardware or software on the machine?
etc....

As a very general tip for this type of situation, you could try booting your machine using a Linux live CD/DVD. Either as a CD, DVD or installed on a USB stick. Once the LiveCD environment has booted, you can mount the internal hard-drive of the machine and do whatever you need to do to solve your problem e.g.:
- Check the HD and its file-systems using …

JasonHippy 739 Practically a Master Poster

If you want to get the result of multiplying the entire contents of a TinyVector by a double and have the value returned as a double, (e.g. double result = myTinyVector * 5.034;) then this might work:
double operator *(const double &x);

Which you could define as:

template<typename T_numtype, int N_length>
double TinyVector<T_numtype, N_length>::operator*(const double &x)
{
    double temp=0.0;
    for (int i=0; i < N_length; ++i)
        temp+=data[i]*x;
    return temp;
}

Is that the kind of thing you're after?

JasonHippy 739 Practically a Master Poster

I wouldn't say that there is a recommended size per se. You pass your container to the random_shuffle function and it will be randomly shuffled.

And regardless of how many items are in a vector; there is always a chance, however small, that the vector will come out in exactly the same order it was originally in. Statistically speaking, the more items are in the vector that you randomly shuffle, the less likely it is that the vector will come out it's original sequence. And the chances of this happening won't be a linear scale either!

I'm rusty with my statistics, but I guess in mathematical terms you could say that for an array with n items, the chances of the sort coming out in the same order is roughly 1 in n! (where n! is the factorial of n)

So if you only had two items in the vector, you have a 1 in 2 (50%) chance of the array coming out in the same order it went in as (2! = 2*1 = 2).

With three items the odds are about 1 in 6 (3! = 3*2*1 = 6).
With four items, it's about 1 in 24 (4! = 4*3*2*1 = 24).
With five, it's about 1 in 120 (5! = 120)
And so on... I'm sure you get the idea!

And again, regardless of how many items are in the vector; even if the vector does come out in exactly the same order it …

JasonHippy 739 Practically a Master Poster

Just spotted that this post hasn't had a reply yet... And I can see why there are no replies now! :/

@Ikhushee: If you would use more meaningful variable names and include some comments in your code, it would allow others here to better understand the intent behind your code/logic.

As it stands, your code is a bit of a mess. I'm not sure exactly what you're trying to do in several places. It's evident that you are trying to create encryption keys and encrypt and decrypt some text using them; But because the variables have unintuitive single letter names and because there are no comments in the code, it's not really obvious what you are doing or what algorithms you are trying to implement. You need to write code so that other programmers can read and understand the logic/intent behind it!

Naming your variables sanely and commenting your code clearly will give others a strong idea of what you are trying to do in your code and will make it easier for others to see any logical errors you've made.

One additional thing I will say is: try not to use too many global variables. Try to keep variables within their particular scope.

Most of the global variables you've declared look like they are only used in main, so they should be declared in main rather than as globals. Global variables should be used sparingly and only where necessary. Globals are visible/in scope in all functions in your program. …

JasonHippy 739 Practically a Master Poster

There are a couple of problems.
1. In your function prototype you have declared and defined a function which has RECORD list[].score listed as the type for the first parameter, which isn't a type at all. This is nonsense!
2. Where you're calling the function you are passing list[].score, which would equate to an int (at least it would if you had given it an index), which could go some way to explaining why you're getting errors about not being able to find a matching function.

You need to pass the entire array to the function. So you should change the signature of the function to:
float calMean(RECORD list[], int count)

Once you've done that, the rest of the code inside your function should work. But you should note that your division operation consists of two int values. And an int divided by an int will return an int. In order to get a float result, you'll need to cast at least one of the two values to float. e.g. return ((float)sum)/count);

And you call the function like this:
mean = calMean(list, count);

JasonHippy 739 Practically a Master Poster

It looks OK to me! I've just tried compiling and running the code you posted in gcc on Linux, just to make sure I haven't missed anything. And it compiles and runs with no nasty surprises. It all seems to be doing what it should!

The scores are created, the search for a score works OK, the randomise also works and finally the vector gets sorted back into the correct order too.

One thing that you do need to bear in mind is that the example only has three scores in it, so it is highly possible that from time to time, the randomise function will randomly sort the vector into the order it was already in. You could try pushing a few more scores into the vector, that should make the results a bit more varied when the vector is randomised! Basically the more items are in the vector, the less likely it is (statistically speaking) that the randomisation will result in the the vector coming out unchanged!

Also if you want some ideas on randomisation, take a look at Narue's article on the subject.

JasonHippy 739 Practically a Master Poster

I could be wrong, but the code you've posted looks OK. I'd guess that the problem is more likely to be in your code which deals with getting input from the user. I suspect that you may only be getting everything up to the first whitespace character in the input stream rather than the entire line entered by the user.

To verify this, try running your program through a debugger:
- Set a breakpoint at the start of your histogram function and run the program.
- Enter a sentence including some space characters
- When the breakpoint is hit, ensure that the string passed into the function matches what you entered.

If the input string matches what you entered, then I've probably missed something silly in your posted code and I'm therefore a complete idiot! But if it doesn't match up, (I suspect it will only contain the first word) you can be 100% sure it's the way that you are getting input from the user that is causing the problem!

Personally, I think it's the code which gets input from the user that is the problem, not your histogram function!

JasonHippy 739 Practically a Master Poster

In both cases, line 5 is the problem.

Looking at Case 1, line 5:
*int_ptr1 = int_ptr2;
int_ptr1 and int_ptr2 are both pointers to int. The Asterisk character (*) is the dereference operator which is used to dereference the pointer. In other words it will give you the value stored at the memory address pointed at by the pointer.
In the above line of code, you are attempting to set the int value pointed to by int_ptr1 to the address of the pointer stored in int_ptr2. So the compiler is warning you that the two types do not match. The types of the arguments either side of the assignment (=) operator do not match, one side is an int and the other side is an int pointer.

In Case 2, line 5; it's exactly the same problem, but the other way around.
int_ptr1 = *int_ptr2
Again, the types of the two arguments either side of the assignment operator do not match. But this time one side is an int pointer and the other side is an int.

This is why you are getting warnings/errors and this is why you are not seeing the results you are expecting!

Depending on what you intend to do, you could do this:
int_ptr1 = int_ptr2;
This sets int_ptr1 to point to whatever memory address int_ptr2 is pointing to (So both pointers point to the same memory address)

Or this:
*int_ptr1 = *int_ptr2;
This sets the value pointed to by …

JasonHippy 739 Practically a Master Poster

Ah, I see the problem!
I've just fired up Codeblocks on a fresh install of Ubuntu 12.04, added build-essential, Codeblocks and all of the OpenGL development packages and tried to create a glut project from the CodeBlocks template and got the error you mentioned.... Very odd. Not seen that before!

I've got to the bottom of the problem though.
/usr/ is definitely the correct path to use. The wizard assumes that the glut header file will be in the /include subdirectory and the library will be in the /lib directory of the location.
From doing a quick file-search of my system, I can see that glut.h is in /usr/include. But the lib file is in /usr/lib/i386-linux-gnu/.
So the wizard is failing because it cannot find the library files. For some reason they are in a subdirectory of /usr/lib/ rather than in /usr/lib/ itself.

The simplest way to fix it is to create some symbolic links in /usr/lib/ which point to the items in /usr/lib/i386-linux-gnu/
So open a terminal and navigate into /usr/lib/i386-linux-gnu/ and run an ls command to see what files are in there:

cd /usr/lib/i386-linux-gnu
ls ./libglut*

For each item listed, create a corresponding symbolic link in /usr/lib/
NOTE: When I did this, I found the following files: libglut.a, libglut.so, libglut.so3 and libglut.so.3.9.0

To create a link for each file, I did this:

sudo ln --symbolic ./libglut.a ../libglut.a
sudo ln --symbolic ./libglut.so ../libglut.so
sudo ln --symbolic ./libglut.so.3 ../libglut.so.3
sudo ln --symbolic ./libglut.so.3.9.0 …
JasonHippy 739 Practically a Master Poster

Have you tried /usr/ (note the additional / at the end.
Otherwise it might be /usr/share
I'll fire up one of my Linux machines in a bit and take a look. (out of my house and on my phone ATM)

very strange, I don't remember C:B ever asking for the location of glut when I've used the wizard for a glut application.....

JasonHippy 739 Practically a Master Poster

It sounds like you don't have the glut development packages (headers and libraries) installed.
I think installing the freeglut3 and freeglut3-dev packages via apt-get will probably do the trick.
I have a strong feeling that they will depend on several other opengl dev packages, so apt should download and install any additional opengl libraries that aren't already present on your system.

So if you open up a terminal/command line and use the command:
sudo apt-get install freeglut3 freeglut3-dev
That should install all of the necessary development files. You might also want to add a version of glew (The openGL extension wrangler) too:
sudo apt-get install libglew1.6 libglew1.6-dev glew-utils

Once that's done you should have all you need. The next time you run CodeBlocks, you should be able to create a new glut project using the project wizard and with any luck, it should also compile and run without any problems!

JasonHippy 739 Practically a Master Poster

In your makefile, you can declare a variable like this:

MYFILEPATH = /home/cmac/

Then for the build targets in your makefile, you can use the variable like this:

targetname: $(MYFILEPATH)filename.cpp
    g++ -Wall -O2 -c $(MYFILEPATH)filename.cpp

Although personally; rather than using an absolute path (like /home/cmac/), I'd use a relative path (e.g. ../cmac/). Obviously your path would depend on the location of your makefile, relative to your source files.

As a quick practical example:
Say I have a main project directory (called myProject) containing two other directories (src and build).
The src directory contains several c++ files:
foo.h, foo.cpp, bar.h, bar.cpp and main.cpp
The build directory will contain the makefile and is where I want the .o files and the final binary to be placed.

So, the makefile is in /home/jason/projects/myProject/build/ and all of the source files are all in /home/jason/projects/myProject/src/
Instead of using the really long absolute paths above, I can use a relative path instead. So to get to the source files from the build directory, the relative path is ../src/. So I can use the relative path (../src/) in my makefile instead!

So my makefile looks like this:

MYFILEPATH = ../src/
CC = g++
CFLAGS = -Wall -O2
OBJECTS = main.o foo.o bar.o

all: $(OBJECTS)
    $(CC) $(CFLAGS) $(OBJECTS) -o main

main.o: $(MYFILEPATH)main.cpp
    $(CC) $(CFLAGS) -c $(MYFILEPATH)main.cpp

foo.o: $(MYFILEPATH)foo.cpp
    $(CC) $(CFLAGS) -c $(MYFILEPATH)foo.cpp

bar.o: $(MYFILEPATH)bar.cpp
    $(CC) $(CFLAGS) -c $(MYFILEPATH)bar.cpp

clean:
    rm ./main ./*.o

That's a pretty extreme example there. Several repetetive bits …

JasonHippy 739 Practically a Master Poster

Tinstaafl's suggestion will at least get rid of the error the compiler is producing. But because your linked list class uses the new keyword to dynamically allocate memory for each node, you really should be freeing that memory in the linked list classes destructor. Otherwise you have a memory leak!

So instead of using an empty destructor, you should consider putting some code in there to free up the memory that was allocated. Simply deleting the head will not be enough, you'll need to walk through the linked list and delete each node. Something like this:

    while(head->next) // equivalent to while(head->next!=NULL)
    {
        ListNode* next = head->next;
        delete head;
        head=next;
    }
    delete head;

For your simple program, the amount of memory that is leaked is very small and is instantly cleaned up by the system as soon as your program ends. In fact it probably doesn't even register as a memory leak at all because the instance of your linked list class is destroyed when it goes out of scope right at the end of your program. And the little memory that was allocated by the class should be automatically freed-up by the system shortly afterwards. But you should be aware that if your class was being used in a larger, more complicated, real-world program. Particularly if the program has to run for a prolonged period of time and has to deal multiple instances of the linked list, storing large datasets each time it was used, then a …

JasonHippy 739 Practically a Master Poster

Gonbe's solution above would be a more logical solution to the problem and would be how I would expect a bool function like this to be used. But again, if it has been specified by your professor that the index of the number should be output by the program, you should use my solution. (I was only going by the information supplied by the OP and went with the assumption that they had to output the index of the number when it was found, otherwise I would have suggested exactly what Gonbe has!)

But if your professor has not specified that you should output the array position of the number when it is found, then Gonbe's answer is bang on the money!

JasonHippy 739 Practically a Master Poster

Took me a little while to understand what you were doing in your code there, it initially looked as if you'd forgotten to return a value from your binarysearch function.

But then I saw in the middle of the binarysearch functions code that you were returning the int value mid. But the function is supposed to return a bool meaning it can only return true or false. So at the point of returning, if mid is equal to 0 the function will return false (or 0). For any other value of mid it will return true (or 1).
Which probably explains your problem.

Changing the signature of the function to return an int would solve this problem, but that isn't what your professor has asked for. He wants you to use a function that returns bool and it can only be assumed that the bool return is intended to signify whether the binary search function failed or succeeded in its attempt to find the user entered value in the passed in array. A bool return value cannot signify the index position of the number in the array. To output the array position you'd need to either:
A: Output the array position directly from inside the binarysearch function when a match is found.
B: Add an additional parameter to your function (a pointer or reference to an int), which would act as an output parameter, then inside your binarysearch function you set the output parameter to the index …

JasonHippy 739 Practically a Master Poster

I'm not a Mint user, but I have used several other Debian and Ubuntu based distros over the last few years. Assuming Mint 13 is based on Ubuntu 12.04 LTS and Mint 14 is based on Ubu 12.10 and assuming Mint isn't too vastly different to Ubuntu under the hood; If anything, it's probably just the release upgrade setting in the software sources options that needs to be set correctly in order to upgrade from 13 to 14.

I can't remember which file you need to edit to set this option from the command line, but if you open the upgrade manager or one of the GUI based package management tools (Software centre, Synaptic etc.. Again, not sure what Mint uses by default) and then go to 'Settings->Configure software sources' to bring up the software sources dialog; then go to the 'Upgrades' tab and set the 'Show new distribution upgrades:' option to 'Normal releases'.

There are two other settings for this option:
'Never' - which means you'll only pick up dist-upgrades for the currently installed version (kernel upgrades etc) and won't get notified when a new version becomes available.
'Long term releases only' - which will only show upgrades when a new LTS version is available.

But setting this option to 'Normal releases' should allow you to pick up any new distribution upgrades.

Once that setting has been made you can either upgrade via the GUI, or you can open a terminal and use:
sudo apt-get update && …

JasonHippy 739 Practically a Master Poster

I wonder if this has anything to do with the problem:
http://www.theregister.co.uk/2013/01/04/turkish_fake_google_site_certificate/

JasonHippy 739 Practically a Master Poster

It might be worth opening whatever sound-mixer software ships with that version of Mint (I'm not a Mint user myself, so I'm not sure what programs ship in the default install), but open the default, system sound mixer program and check that all relevant channels are enabled, are not muted and are turned up.

In the past I have seen cases where on first boot, the mixer has either started with the master channel muted, or has the master volume up and has the volumes for one or more of the other audio channels muted, or turned right down to zero.

You can usually access the full mixer by clicking or right-clicking on the volume/speaker icon in the notification area of the system tray and selecting an option (usually something like 'open mixer'), then there is usually something in the options which allows you to show/hide the sliders for the different channels. Show/Enable all of the sliders and check their settings (you can hide any irrelevant sliders again once you've checked them all)

It could also be that the device settings in the mixer are incorrect. So take a look at those. (e.g. In the mixer programs options, you might need to ensure that the 'OSS mixer' option is selected in the analogue devices section)

If none of the above works, what output do the following commands give you?
lspci | grep -i audio - should list any bits of audio related hardware it finds
lsmod | grep -i snd

JasonHippy 739 Practically a Master Poster

The instance of the Uzenet class which you are passing into your function is called uzenet (note the capitalisation). So in the function, where you are trying to call member functions of the class, you need to use the instance name (uzenet) NOT the class name (Uzenet).

JasonHippy 739 Practically a Master Poster

@OP: Ah, I thought the -4 was meant to be a value for the -c parameter. I didn't interpret your 1st post properly. I should have noticed that the -c parameter doesn't require a value and that the -4 referred to the -k option.

After seeing your 2nd post, that clears things up massively. Yes L7Sqr is correct. You need to be using -k 4!

So to correctly invoke the program you need to use the following:
./example -c -k 4 -i input.txt -o output.txt

For Future Reference:
When dealing with parameters to programs, you must always specify which parameter you are using. If a parameter takes a value (like with -k in your example program) you put the value after the parameter name. E.g. -k 4.

Sometimes the order of the parameters matters, in other programs it does not. If you are ever unsure of which parameters are mandatory and which are optional and/or the order in which they are supposed to be used there are several ways you can get help.

Getting Help:
On Linux systems, most command line programs will display some help if you invoke them incorrectly. Quite often, using the -h switch as a parameter will display help too. Sometimes programs require --help as a parameter, in rare cases like your 'example' program it might also accept ?.

Many Linux system programs also have detailed help available which can be accessed via the terminal using the man command. So for example if you …

JasonHippy 739 Practically a Master Poster

AFAIK, minicom should be in the Ubuntu repositories. Have you tried this?:
sudo apt-get install minicom
That should be all you need.

JasonHippy 739 Practically a Master Poster

I think you need to be doing this:
./sample -c 4 -i input.txt -o output.txt

JasonHippy 739 Practically a Master Poster

On my phone ATM so can't test it out or anything. But in principle, it looks OK to me. Might be worth getting another opinion though. I'm a little rusty with regex's myself! :)

JasonHippy 739 Practically a Master Poster

When you're saving your image out from photoshop, what file-format are you using?
I'll assume that you are using a lossey format (.jpg, .png etc)

Also when you import your image into the flash IDE, what quality settings are you using?

For now, I'll assume that you are importing the image into the library for your flash project and then using it in a Movieclip or a Sprite and using the default settings for the image quality.

It's been a while since I've done anything with Flash, but I seem to recall that when you import lossey images (.jpeg, .png etc) into the Flash IDE; the IDE usually tries to compress the image a little when you export to .swf. So you get a smaller .swf at the expense of the quality of the embedded images. I can't remember what the default quality value is for images (75%?), but there is a way to set the quality of each image you import into your project in the flash IDE (I can't remember if it's a global setting in the export settings, or if it's a per-image setting in the library). If you set the export quality of each image to 100%, it should be uncompressed in the swf and should appear exactly the same as the original, but this will increase the file-size of your swf.

An alternative to embedding images is to dynamically load them at runtime. Loading external images can sometimes be better than embedding them in …

JasonHippy 739 Practically a Master Poster

Put simply the difference is; each key/value pair in a std::map must have a unique key. Whereas a multimap can contain key/value pairs with duplicate keys.

JasonHippy 739 Practically a Master Poster

@crazyjdog: Another thing I can see that is wrong with your code is the extra instance of GeometricObject you're creating in your main() function. You don't need to do this. You have already declared the Triangle class to be derived from GeometricObject, so why not just use those GeometricObject class properties in your triangle class?

You can do this by altering the __init__ function for your Triangle class to take color and filled as additional parameters, then pass color and filled to the superclasses __init__ function. That will correctly initialise the base-class part of a Triangle instance
e.g.

def __init__(self, side1 = 1, side2 = 1, side3 = 1, color="Green", filled=True):
    super().__init__(color, filled)
    self.side1 = float(side1)
    self.side2 = float(side2)
    self.side3 = float(side3)

Then in your Triangle classes __str__() function, wherever you want to output the properties of the GeometricObject base of a triangle you simply call:
super().__str__()

e.g. in the Triangle classes __str__() function:

def __str__(self):        
    return  "Triangle: side1 = {!s}, side2 = {!s}, side3 = {!s}, {!s}".format(self.__side1, self.__side2, self.__side3, super().__str__())

Note: I've used str.format() because I think it looks a little nicer than the "foo = " + __foo + ", bar = " + __bar style of string building.

Also note: When the super().__str__() function is called, you will end up with a malformed string because the value you get for the filled variable in main() is not a bool. Therefore the value of __filled inside the class is also not strictly boolean. …

JasonHippy 739 Practically a Master Poster

The error you're getting is because your setArea function has not been called before the getArea function is called. setArea is where self.__area is first declared/initialised.

So as your code stands, as far as the python interpreter can see, your class does not have a property called __area

Personally I'd scrap the setArea and setPerimeter functions and create a class function called recalulate instead which will calculate __area and __perimeter:

def recalculate(self):
    self.__perimeter = self.__side1 + self.__side2 + self.__side3
    s = (self.__side1 + self.__side2 + self.__side3)/2
    self.__area = sqrt(s*(s-self.__side1)*(s-self.__side2)*(s-self.__side3))

Then call self.recalculate at the end of your class constructor.
You might also want to call self.recalculate at the end of the three setSide functions to recalculate the area and perimeter of the triangle when one of the sides has changed.

JasonHippy 739 Practically a Master Poster

That's strange, so it's saying that you have gcc v4.6, but you aren't able to use it.
In fact file says that the gcc file you have is data and not an executable....hmm..
And according to your system information you don't have a default compiler installed.....

Have you installed the build-essential package yet? When you said gcc wasn't working I assumed that you at least had gcc installed, but now I'm thinking you don't have it at all....
I recommend installing build-essential with the command: sudo apt-get install build-essential
That would be my first suggestion. That package provides all of the packages you'll need to be able to compile from source(including gcc).

Hopefully that should solve your problem!

JasonHippy 739 Practically a Master Poster

Oops! You were supposed to run the 'file' and 'ldd' commands before doing anything to see what they said! Never mind, my bad! Looks I didn't explain myself clearly. I meant for you to run the two commands first and see what output they gave you. I suspected you were running 32 bit executables on a 64 bit machine. The output of both of those commands would have confirmed this if it was the case!

And if it did turn out to be the problem, that was when you should have installed the two packages. But that's a moot point now because you said that you are running a 32 bit system, so it looks like I was completely wrong. Sorry about that!

So those packages aren't going to help at all... you'll probably want to uninstall both of them using sudo apt-get remove ia32-libs gcc-multilib. Perhaps followed up with sudo apt-get autoremove to remove any unused/orphaned packages that the two removed packages depended on (if there are any!).

That should get you back to where you were before.
Once you've removed those two packages, try running the 'file' and 'ldd' commands on /usr/bin/gcc and see what it says. It might yield some clue as to what's going on!

I'm not sure what to suggest.....Perhaps purge gcc and reinstall it?
sudo apt-get purge gcc && sudo apt-get install gcc
Actually, hold off on doing that for now. I'll take a look at my Kubuntu install and investigate what …

JasonHippy 739 Practically a Master Poster

Open up a terminal and try the following commands:
file /usr/bin/gcc
and:
ldd /usr/bin/gcc
What output do they produce?

Also is your system 32 bit or 64 bit?

I have a feeling that you may be running a 32 bit version of gcc on a 64 bit machine, at least I think that's what usually causes this error!

If this is the case, then you probably need to install the gcc-multilib package:
sudo apt-get install gcc-multilib

If this doesn't fix the problem, you might also need the ia32-libs package, which allows you to run 32 bit apps on a 64 bit OS. Again, use sudo apt-get install ia32-libs

Hope this is of some help!

JasonHippy 739 Practically a Master Poster

@IAMADOG: Your foul language and immature, unprofessional attitude is hardly helpful!

Judging by the OP's code it looks as if they are having to use a really old Borland compiler.

FYI: Many schools/colleges/universities in places like India and Pakistan force their students to use ancient, outdated Borland C/C++ compilers.... Quite why is beyond me, surely it would make more sense to use something like CodeBlocks with mingw and allow their students to learn up to date, standards compliant C and C++. But then perhaps it is the teachers who learnt C/C++ on those old compilers who are too lazy to update their knowledge by learning how to use an up to date version of the language! IDK!

Unfortunately people like the OP have to put up with it!

So the OPs use of .h at the end of the header #includes is to be expected because their compiler requires it! Also I'm not sure if the std:: qualifier is needed for cin and cout either because their C++ compiler could pre-date the formalisation of the C++ std::library!

I can't remember too much about the old Borland C++ compilers syntax, but I would at least expect iostream.h to be present in the #include list!

@ANJALIRWT: If I were you I'd separate your code out into several files.
So create a header file and a corresponding .cpp file for each of your classes. Then include the headers for your classes in your main file (or anywhere else they may be required!).

deceptikon commented: Excellent reply. :) +11
NathanOliver commented: Excellent example +0
JasonHippy 739 Practically a Master Poster

Hmm, I don't know what to suggest. It's probably some lightweight alternative bit of software that Xubuntu uses that is causing the problem. Perhaps a driver or a codec or something! Either way there is something that KDE uses that XFCE does not. But I couldn't tell you exactly what it is!

With most Linux distros, you can install as many desktop environments as you like and you can usually choose which desktop session to use at the login screen (depending on the chosen Display/login manager). And this is true of the Ubuntu family of distros.

So if the problem is fixed in Kubuntu, but you want a lighter desktop experience you could always try installing the Xubuntu/XFCE desktop (not the distro) on top of Kubuntu. After installing the xubuntu desktop and then logging out and switching to an xfce session, your problem MIGHT be fixed.

Alternatively, there is a newish, lightweight, QT-based desktop called Razor-QT which offers a lightweight desktop experience for KDE users. The desktop itself looks and feels a bit like Gnome2 or Openbox and is really fast and responsive compared to the full-fat KDE experience, which can be quite slow on lower end machines!

To install Razor-QT in a Ubuntu based distro, open up a command line and enter the following commands:

    sudo add-apt-repository ppa:razor-qt/ppa
    sudo apt-get update
    sudo apt-get install razorqt razorqt-desktop

Razor-QT doesn't have it's own network management applet yet (the KDE network management applet is a Plasma plugin, which Razor doesn't …

JasonHippy 739 Practically a Master Poster

$PIPESTATUS is an environment variable that holds the return values from any single, or chained commands in an array.... The page here should explain it far better than I can!:
http://www.linuxnix.com/2011/03/pipestatus-internal-variable.html

The && is a logical/boolean AND, similar to C, C++, Java etc.
As far as I understand it, the && inside the braces is part of the compound, boolean expression based on the commands contained in the braces. The && at the end of the line means that the next command (or line) in the bash script will only be executed if the commands to the left of the && (so basically if everything inside the braces) succeeds. So the next line or command in the shell script is the right hand part of the AND at the end of the code you've posted.

So it's kinda like:
If (make 2>&1 OR tee make.log AND exit $PIPESTATUS) AND NextLineOrCommand.....

So it's just a way of conditionally chaining several commands together.
At least I think that's the way it works!

JasonHippy 739 Practically a Master Poster

The description of your problem is a little vague. What does your program do?

If you post a snippet of your code which encloses the part that is going wrong, including anywhere where the incorrect value is being accessed or modified, somebody might be able to post some insight into the problem.
Without seeing some code, or some more specific information about the problem I don't think anybody can help you.

Otherwise, have you tried running the program through a debugger like gdb at Uni? If you use gdb you can step through your code and see exactly what is going on in your program, which should help you to isolate where things are going wrong.

Assuming that you aren't particularly au-fait with g++, gdb and/or Linux:
In order to be able to use gdb effectively you need to generate debug information when you compile your program. You can do this by using the -g option on the command line.
e.g. g++ myprogram.cpp -g -omyprogram -Wall

This is equivalent to doing a debug build in visual studio.

Then you load the 'debugger friendly' executable into gdb.
e.g. gdb ./myprogram

Once inside gdb, you can list your program using the 'list' command and you can set breakpoints by using 'break {linenumber}'
Then use the 'run' command to run the program up to your first breakpoint.
Once stopped at a breakpoint you can use 'inspect {variablename}' to see the value stored in any variables that are …

JasonHippy 739 Practically a Master Poster

Hmm, there are more problems than that in there.

If you look at the code properly, there are actually two extraneous braces in the middle of the class declaration. The two occurrences of }; should be removed at lines 14 and 15.
The brace at line 17 is the start of the body of the show_employee member function of the employee class, so you'll need to remove the semi-colon ; from the end of line 16.
Also you need to remove the semi-colon at the end of line 28 where you are defining your main() function. And there's another extraneous }; at line 46 which should also be removed!

Once you've fixed the problems mentioned above, you'll get error messages about the use of the variables 'worker' and 'boss' because you haven't declared them.

Then there are the character arrays you've declared. What are they for?
If the character arrays are meant to be instances of your class, then you are doing things drastically wrong. You need to declare them as you'd declare any other variable.
e.g.

employee worker;
employee boss;

There may be more problems with your code, but those are the most obvious ones that I can see! :)

JasonHippy 739 Practically a Master Poster

That doesn't work for me. As already explained, there is a hardware switch on my laptop to enable/disable the wireless card. I've tried other distro's and the hard switch and the wireless card works properly with no problem.

On the Arch drive, I think the problem is ACPI related or something. For some reason the state of the wireless switch is either not being monitored, or something is reporting the state of the switch incorrectly. I've tried everything I could think of and everything I found on the internet about these kinds of problems. Even wiping the Arch drive and re-installing Arch from scratch didn't solve the problem. The result was the same. On Arch there is suddenly no way to enable my wireless card. The card is recognised, but is never enabled because Arch thinks that the hard switch is always off (even when it is blatantly on!)

In the end I went back to Crunchbang with DWM and Openbox as my WMs of choice. Being Debian based, Crunchbang uses slightly older packages, but I can live with that for now.
I'll probably try Arch again in a few months to see if the problem has been fixed. Maybe it was something I'd picked up in a recent update to the system or something. Or perhaps some kind of config setting that I'd missed. Either way Arch is the problem because the wireless problem was only occurring under Arch!

Very odd!

JasonHippy 739 Practically a Master Poster

Seeing as this thread is 5 months old, I guess replying to this is pretty much pointless. But seeing as umesh and Rubberman have resurrected it, I figured "what the heck?!". There are a few obvious errors in the code that I can see (other than the lack of code tags and indentation). So here goes:

  1. The 'Node' structure should be declared before the 'Lists' class.
    Because 'Node' is a member of the 'Lists' class, the compiler will need Node to be declared/defined before the 'Lists' class, otherwise it will throw errors about 'Node' being undefined.

  2. The 'tail' member of the 'Lists' class should be initialised in the class constructor.
    As the OPs code stands, the lists 'tail' member is completely uninitialised. So the call to temp.print() in main() will almost certainly cause a segfault/crash at runtime when it attempts to access the tail of the list.

  3. In the 'Lists' class constructor, it should be noted that the 'Node' structure doesn't have a member called 'Link', but it does have a member called 'link'. So the lines 'head->Link=tail;' and 'tail->Link=NULL;' should be edited appropriately.

  4. In the main function the call to 'system("PAUSE")' should be made before the return statement, not after it! In fact if you want to be completely anal about it, system("PAUSE") should not be used at all. But whatever floats the OP's boat!

There may well be other problems/errors in the OP's code, but the four problems listed above stuck out instantly!

JasonHippy 739 Practically a Master Poster

In python there is a boolean type, but its states are True and False (note the capitalisation of the first letters)

So in your program all occurrences of false should be False.

Also, you are defining guess as a bool and then later you are using it as an int. I think you mean to use two variables here rather than one.
So 'guess' would probably be a good name for the int variable used to store the users current guess. But perhaps the boolean should be called something like 'isCorrect'

So the start of your program will look something like this:

#Guess my Number game Ch 3
import random
attempts = 1
number = random.randint(1,100)
isCorrect = False

while isCorrect == False:
    #... The rest of your code ...
JasonHippy 739 Practically a Master Poster

Hmm, that's strange, it looks like they are identical and are both executables.
python3.2 should be the actual python executable and python3 should be a symbolic link which points to the python3.2 executable.

What distro are you running ATM?

Using ls -l /usr/bin/python* yields the following results for me (Kubuntu 12.04):
/usr/bin/python -> python2.7
/usr/bin/python2 -> python2.7
/usr/bin/python2.7
/usr/bin/python3 -> python3.2
/usr/bin/python3.2 -> python3.2mu
/usr/bin/python3.2mu
/usr/bin/python3mu -> python3.2mu

NOTE: I've snipped all of the file-permissions, owner/group, filesize, timestamp information as it is irrelevant. The files with arrows '->' next to them are symbolic-links (or symlinks for short).

Looking at my results you can see that /usr/bin/python is a symbolic link to the python2.7 executable (/usr/bin/python2.7). So the system-wide, default version of python used by my system is python2.7. Therefore any time a program tries to start python by opening /usr/bin/python (or just 'python'), python2.7 will be used.

The /usr/bin/python2 symlink is also set up to use python2.7, so any applications which start python by opening /usr/bin/python2 (or 'python2') will also use python2.7

Then there are several symlinks set up which point to the python3.2mu executable.
So any programs using /usr/bin/python3, /usr/bin/python3mu, or /usr/bin/python3.2 will end up using the python3.2mu executable.

Basically, the symlinks allow you to update/upgrade your python executables to new versions without having to reconfigure all of the programs that need to use the python interpreter.

So if you have a program which requires any version of python2.x (or …

JasonHippy 739 Practically a Master Poster

Take a look at my reply in the thread you posted in the Linux/unix forum:
http://www.daniweb.com/hardware-and-software/linux-and-unix/threads/434063/python3-linux-directory

There are instructions at the end of the post that should allow you to setup geany to use python3 instead of python2.

JasonHippy 739 Practically a Master Poster

AFAIK zlib support should be built into Python.
So I think it's most likely that you just need to install the zlib libraries/.so's onto your system. Just open your package manager and search for zlib and then install the appropriate files.

Although, from seeing some of your previous posts; I know that you've been trying to build a LFS system too. So if this problem is on your LFS machine and you built Python yourself, you might want to consider installing the zlib libraries and development files before reconfiguring and rebuilding Python from source. There's probably an option to explicitly enable zlib. Otherwise when you ran ./configure on the previous build; perhaps the configure script failed to find the zlib libraries and/or headers and automatically set an option to disable zlib support.

But if it's a stock install of a pre-built distro, it's far more likely that you simply don't have the appropriate zlib libraries/.so's installed.

Either way, installing the zlib libraries (and development files in the case that a rebuild is required) should solve the problem..... I think!
Also, if you are on a 64-bit system, you might want to make sure you have the 64-bit and 32-bit versions of zlib installed!

JasonHippy 739 Practically a Master Poster

This should work:

def texten():
    filehandle=open ( 'savetonight.txt', 'r' )
    text=filehandle.read()
    return text

def smabokstavertext():
    text = texten()
    print text.lower()

Basically, where you were calling texten, you need to create a variable to store the returned value.

So inside your texten function a local variable called 'text' is created, populated with the contents of the file and then returned.
Inside the smabokstavertext function, you now have another local variable called 'text' (this is not the same object, it is a separate object), which gets assigned the value returned by the call to the texten function.

ZZucker commented: helpful +7
JasonHippy 739 Practically a Master Poster

Another way is to open up a command line and use the which command.
The which command will tell you the path of an executable.
So if you want to find out which python3 executable is being used you would simply use:
which python3. This will output the path to the python3 executable (or it might be a symbolic link). As Rubberman has said, this will almost certainly be in /usr/bin.

If you're ever unsure where an executable is located; as long as it is somewhere in a directory specified in the system $PATH environment variable, you can use the which command. Once you've got the path, you can open up that directory and use ls -l to see whether it is a symbolic link to another executable file, or if it is the actual executable itself.

I'm not sure about changing the raw /usr/bin/python to point to python 3 though because python is integrated into most, if not all distros. And AFAIK, all distros ship with python2.x by default (usually 2.6 or 2.7 nowadays). I don't think any use python3 as the default yet. So /usr/bin/python is usually linked to python2.
I'd guess that changing /usr/bin/python to point to the python3 executable could cause any system scripts/programs which use python2.x syntax to fail because they'd end up being ran by the python3 interpreter. So I don't think that is the way forward.

On the subject of using python 3 with geany, a quick search has yielded …