JasonHippy 739 Practically a Master Poster

Looks like you need to install libcurl-dev. Offhand, I'm not sure of the exact package names on Ubuntu. Your best bet would be to take a look for them in the software centre or to try opening a terminal and run the command apt-cache search --names-only libcurl | grep -i dev - That should list some packages. Once you've identified the appropriate package for libcurl-dev, use sudo apt-get install xxxxx where xxxxx is the name of the package you need to download/install.

After installing libcurl-dev and running configure again, you might get similar errors about other missing libraries/dependencies. If this happens you'll need to download/install more dependencies as per the above instructions.

Once you have all of the dependencies installed the configure step will eventually succeed and you should be able to move-on to actually compile/build the program!

JasonHippy 739 Practically a Master Poster

I don't know of any direct Swishmax clones/alternatives on Linux.

The closest I can think of is Synfig - a 2D animation program which I believe can export animations as flash/.swf format (amongst many other formats). So synfig might be OK if you only want to create animations.

Blender (although traditionally a 3D CAD/animation type program) can also be used to create 2D animations (along with many other things like compositing, non-linear video editing, game creation with the built-in game engine etc) - But Blender has quite a steep learning curve!

If you want to create more interactive content like games, IMHO the best bet would probably be something like the Adobe Flex SDK which will give you the tools required to compile/build .swf files from AS3 and mxmlc files. But this means that you will be doing everything in code. If you are comfortable writing code, you shouldn't have a problem using the flex SDK. But if you're one of those 'spaghetti-code nested inside clips and all over the timeline' type flash-devs, you probably won't get on well with it!

Also when using the Flex SDK you'll need to either create your graphics in code, programmatically (which requires a bit of maths/geometry/trigonometry knowledge), or you can use another external image editor like Inkscape to create scalable svg GFX or Gimp/Krita for bitmap/raster GFX and then write AS3 code to import (or embed) and manipulate the GFX in your project.

There is also a program called Minibuilder, which …

JasonHippy 739 Practically a Master Poster

Regenesis by Kinasis
Yes, my own band.... Sad, I know! But we have a gig in Bristol tomorrow night and I've been drumming along on my practice pads in preparation. And it was the last song I ran through.. So nah! Heh heh! :P

Here's the official lyric vid for the song: (Taken from our as yet unreleased debut album 'Divine Self-Invention')
http://www.youtube.com/watch?v=N1MAlkkOQvQ

Note: Although we're a metal band, the vid is safe for work. There's no swearing in the song or offensive content in the vid. But it's definitely loud and not exactly what you'd call music! Heh heh! XD

JasonHippy 739 Practically a Master Poster

No, you don't need to reinstall the whole OS. You might just need to download some drivers.

Rubberman was merely stating that there might be some pieces of hardware on your machine which require proprietary drivers and that proprietary drivers might not be installed when the Ubuntu operating system is first installed.

To troubleshoot this problem, open a terminal in Ubuntu and run the two commands specified by rubberman (lspci and lsusb) and repost their output.

The lspci command will list details of hardware connected to your pci bus. The lsusb command will list details of USB devices connected to your computer. This will give an idea of what hardware devices you have.

Also lspci -v will show more detailed information about the hardware, including the name of the Linux kernel module/driver which handles that piece of hardware (if any). That might help to track down any driver problems.

Once we can see what hardware you are using, someone here will be able to direct you to the correct drivers, if any are required.

Also, you mentioned network problems. What output do you get from the command ifconfig? That will show the networking status of your PC in Ubuntu and will show which, if any of your network interfaces are configured and running.

rubberman commented: Good reply Jason. +12
JasonHippy 739 Practically a Master Poster

Well, take a look at the url from a search page on google.
I went to google.com and did a search for daniweb.com and got this URL for the results page:
https://www.google.co.uk/?gws_rd=cr&ei=f0UFU-y9CoeK1AW4joGgCw#q=daniweb.com

Looking at that URL, the question mark "?" in the URL indicates the start of the variables that were passed to the search engine in order to generate the results page. The actual search terms are at the end of the url "#q=" indicates the start of the search terms that were used. So it should just be a case of adding "#q=" and your search terms to the google URL.

So if you want to use the script to fire up the browser and search for something, you could have a string variable called googleUrl, which is assigned the value "http://www.google.com/?#q=". This forms the base of the required URL for a search.
Then in your script you could get the user to enter their search terms as a string.
Finally append the users search string to the googleUrl string and open that in your call to webbrowser.open. That should open the browser and perform the search.
e.g.

import webbrowser
new = 2
googleUrl = "http://www.google.com/?#q=";
terms = input("Enter your search terms: ") # or raw_input if using python 2
webbrowser.open(googleUrl + terms, new=new)

Otherwise, if you just want to hard-code the search terms into the script, simply add the terms after '#q=' in the …

JasonHippy 739 Practically a Master Poster

I didn't mean that boost was bad. Far from it! The boost libraries are great!
It's a portable, mature, stable, well-tested set of C++ libraries that are extremely useful.

My comment refers to the fact that some people don't like making their programs rely on an external library for something trivial like this. If you compare the two examples in my post; the 2nd example is extremely simple and understandable and doesn't require a 3rd party library.

At the end of the day, boost::assign::map_list_of is little more than syntactic sugar. It provides an alternate means of initialising a std::list.

Some people (including myself) would consider it overkill to add the boost library as a dependency for just map_list_of! (The only reason I mentioned map_list_of was because it allows you to use similar syntax to your original code)

But the boost library is a great library. I heartily recommend taking a look at it. There are some extremely useful classes available in there.

If you want to use boost, by all means do so!
Personally, I'll only use the syntactic sugar provided by boost::assign if I'm already using other, more significant boost components elsewhere in my program (boost::bind, boost::signals2, boost::filesystem, boost::graph etc). In for a penny, in for a pound and all that! Heh heh! :)

JasonHippy 739 Practically a Master Poster

The compiler does not know where COLOR_BGR2HSV is defined.
I suggest you take a look at the documentation for the OpenCV library and see if you can find the header file that COLOR_BGR2HSV is defined in and ensure it is #included in your source file.

Second thoughts:
From a quick poke around on the net I've found this:
http://opencv-srf.blogspot.co.uk/2010/09/object-detection-using-color-seperation.html
Which contains the following line:
cvCvtColor(frame, imgHSV, CV_BGR2HSV); //Change the color format from BGR to HSV
Which looks as if it is exactly what you are doing at the line where you are getting your error. So perhaps COLOR_BGR2HSV is actually incorrect. Perhaps you should be using CV_BGR2HSV instead!

JasonHippy 739 Practically a Master Poster

I don't think you can initialise a std::map like that.

You can initialise std::map in a similar way using map_list_of in the boost::assign library.
Which would allow you to do something like this (if memory serves):

void ArcherArmor::ArcherArmor_shop(){
    soldier_armor = boost::assign::map_list_of<int, Armor> 
        (1, Armor("Meito Ichimonji", 4, 150, 1)) 
        (2, Armor("Shusui", 10, 230, 2))
        // ....Rest of your map declarations
        (6, Armor("Soul Calibur", 60, 900, 8));
}

But if you don't want to add boost as a dependency to your program, your best bet would probably be to do something like this:

void ArcherArmor::ArcherArmor_shop(){
    soldier_armor[1] = Armor("Meito Ichimonji", 4, 150, 1);
    soldier_armor[2] = Armor("Shusui".......
    //and so on....
}
JasonHippy 739 Practically a Master Poster

C++ is case sensitive. Change line 5 of your header file from class salaried to class Salaried (Note the uppercase S) and that problem should go away!

Effectively you have declared a class called salaried in your header, yet your cpp file contains definitions for Salaried. So the compiler is complaining that it doesn't know what 'salaried' is.

Also FYI: It looks as if you have the private and public members of your class the wrong way around. Shouldn't the member functions be public? and the data members private? You might want to review that! :)

JasonHippy 739 Practically a Master Poster

What about:
cp*[24680].enc or cp*[24680].* ?

So if the files are all in the current directory and you want to copy the even numbered ones to a sub-directory called "even" you could do the following:
Using cp (or mv):
cp ./cp*[24680].enc ./even/
or
cp ./cp*[24680].* ./even/

or using the find command:
find ./ -type f -iname "cp*[24680].*" -execdir cp {} ./even/ \;

EDIT:
Note: Unless you specify a maxdepth for find, it will look for files recursively in any sub-directories, which you might not want it to do.
To make it only search in the current directory you can do this:
find ./ -maxdepth 1 -type f -iname "cp*[24680].*" -execdir cp {} ./even/ \;

JasonHippy 739 Practically a Master Poster

I don't know of any built in pow function in Haskell (I'm still a novice with it myself), but off the top of my head, you should be able to create a simple pow function like this:

pow :: Int -> Int -> Int
pow x y = x^y

Which you call like this:

pow 3 2

Where 3 is the base value and 2 is the exponent, which should calculate and return the value of 3^2, which is 9!

With regards to the rest of your program, I'm a little confused. The description doesn't make sense.

I'm assuming you need to get the user to input a value for n, which you need to check is positive.
If the value is acceptable, you then calculate the series of values. Looking at the formula you have given, it looks as if it will require a recursive function starting with n^2 and counting down on each recursive call until you get down to 1.

So using the pow function above, we could create a simple recursive function like this:

powthing :: Int -> Int
powthing n
    | n < 1 = 0
    | n == 1 = 1
    | otherwise = pow n 2 + powthing (n-1)

Note: I had no idea what to call this function, so I've simply called it powthing! :)

In the above function, we have a few checks against the value of n. If n<1 we return 0, if n==1 we return …

ddanbe commented: Great job! +15
sepp2k commented: +1 +6
JasonHippy 739 Practically a Master Poster

The reason you are seeing "scientific notation type numbers" in your output is because your program is storing and manipulating double values. And double is a floating point type which can represent a greater range of values than float and uses scientific notation to represent values.

If you want your program to only use and display integer values you should change your arrays to use an integer type (unsigned int, int, long etc) and update the rest of your code accordingly (e.g. instead of taking doubles as parameters to functions, take the appropriate integer type).

Otherwise, if you want to store all of the values as doubles and output some of them as integers; when outputting the values you want displayed as ints, you can cast them to an integer type using the static_cast operator.

It's not that your program is displaying your data incorrectly, it seems more like you have chosen the incorrect type to represent your data!

JasonHippy 739 Practically a Master Poster

But the descriptions contain links to the source code, which is probably why Tony posted these vids.

Take another look at the videos and follow the links in the description. Then you can download and examine the source code for the examples demonstrated in the vids. From taking a quick look, the code is quite simple and more or less speaks for itself and shows how to implement scrolling.

JasonHippy 739 Practically a Master Poster

Show us your code and we'll show you ours! :P
Check out the community rules, particularly this rule:

  • Do provide evidence of having done some work yourself if posting questions from school or work assignments

In your post, you have provided no evidence that you have done anything towards this assignment/project. You should know that the community here does not exist to do your homework for you. We are merely here to help guide you when you have problems.

The best advice I can give you ATM is this:
You have a pretty well defined problem set, it's not particularly difficult. Just sit back, take another look at the problem, have a bit of a think and break it down into a sequence of logical steps that you can translate into code. Then write your code and see what happens when you try compiling and running it!

Once you've done this, if you have any problems with your code, please post again. And when you do so, please ensure you include the following:

  • A description of the problem/s you are encountering
  • A short snippet of problematic code
  • Any error messages from the compiler
  • Any other useful, relevant information that you think might help us to help you!

:)

JasonHippy 739 Practically a Master Poster

From looking at your cout statements, e.g. line 58:
cout << name << age << sex << score << endl;
Your output is not being spaced because you aren't putting any spaces between any of the output values. You might want to consider inserting some whitespace between each variable you output. Either by using one or more space characters in a string or using "\t" for a tab e.g.:
cout << name << " " << age << " " << sex << " " << score << endl;

Another observation:
In lines 61 - 82, (your male/female calculations) you might want to take another look at the conditions used in your if statements:
e.g. line 61: if (sex=='M' && age > 7) - corresponds to males who are over the age of 7, NOT males under the age of 7.
Likewise, line 68: else if(sex =='M' && age < 8) - corresponds to males who are under 8. NOT males who are over 7!
Line 75 is OK; but again, line 82 is incorrect:
else if(sex =='F' && age < 8) - would correspond to females under the age of 8, NOT females over the age of 7.
So you should update the conditions of those if statements accordingly. I'll leave you to work out what values to put in there!

Eagletalon commented: Very helpful and supporting, not belittleing, what I like to see +3
JasonHippy 739 Practically a Master Poster

I think this might be to do with the version of sed that you are using.

I think the default version of sed which ships with recent versions of the Mac OSes is based on the FreeBSD version, which doesn't contain the GNU extended regex syntax.
You could try using the -E switch to see if that works. Otherwise, perhaps you should consider installing GNU sed on your Mac!

Installing GNU sed might be the best option (either build and install from source, or install via homebrew/port). GNU sed is the version of sed you're already using under Cygwin on Windows. That way your original script will work on Windows, Linux and Mac without modification.

The only other option of course, would be to read the documentation for the version of sed which is installed on your mac, learn what regex syntax is supported and modify the Mac version of your script accordingly.

rubberman commented: Good suggestions. +12
JasonHippy 739 Practically a Master Poster

I have Notepad++ installed on my Windows PC at work and there are three plugins which I use for writing Python scripts:

  1. Python Indent - This plugin is very handy. It will automatically indent your code as you type (but you need to enable it after installing it by selecting 'Plugins->Python Indent->Enable' in the menu)
  2. Python Script - The Python Script plugin (as posted by snippsat above) allows you to programmatically script events in Notepad++ (i.e. automate things inside Notepad++ using python scripts). It can also be used for running other python scripts, but personally I only use the Python Script plugin for automating Notepad++. For most python scripts I use the following plugin...
  3. PyNPP - The PyNPP plugin gives you three additional keybinds to run python scripts:
    ctrl-alt-F5 = Run script in Python
    alt-shift-F5 = Run script in Python Interactive
    ctrl-alt-shift-F5 = Run script in PythonW

NOTE: The keybinds listed above for PyNPP are the default ones that are set when you install the plugin.
If you want to modify them, you can use the 'Run->Modify shortcut/Delete command' menu item to edit the shortcuts. You need to select the 'Plugin commands' tab and scroll through the list of plugin commands until you find the ones for PyNPP and you can edit the keybinds by right clicking on them and selecting 'modify' .

Using PyNPP is simple. You just write your .py file, save it and then hit the appropriate key-bind to run your program. …

Gribouillis commented: very informative post +13
JasonHippy 739 Practically a Master Poster

That's a boolean expression, so the value of F will be true or false dependent on the value of i. The ! (NOT) operator in the expression inverts the result of the i>10 comparison.

So if the value of i is greater than 10, the result of the expression i>10 is true, the ! operator inverts it to false. Therefore if i is greater than 10, the value of F will be false.

Likewise, if i is less than or equal to 10, the value of F will be true - because the result of the expression i>10 will be false and the ! operator inverts the value to true.

JasonHippy 739 Practically a Master Poster

OK, After a bit of searching online and reading various man pages (RTFM FTW!) I've come up with this:

#!/bin/bash

ls ~/Pictures/Screenshot*png > /dev/null 2> /dev/null

if [ $? -eq 0 ]
then 
    find ~/Pictures/ -name "Screenshot*png" -type f -print0 | ( 
        while read -r -d "" FILENAME 
        do 
            FILENAMES=("${FILENAMES[@]}" "$FILENAME")
        done

        for FILE in "${FILENAMES[@]}"
        do
            mv "$FILE" ~/Pictures/Screenshots/
        done 
    )
fi

Like your original script, it uses the result of the initial ls command to check whether there are any files to move. If there are files to move, we use the find command to get the names/paths of the files to be moved, using the -print0 option to null terminate each result rather than appending a newline to each.

As far as I understand it, doing this puts all of the results from find into one long line of text and each filename in the resultant string ends with a null.

Next we pipe the output of find to the rest of the script.

The next part of the script uses the read utility in a while loop to tokenise the string output by find into each separate filename (including any whitespace characters or other special/escaped characters). Using "" as a delimiter in the call to read makes the read utility read up to the first null it finds, so any special characters are kept intact in each file-name.

Each filename is read into a variable called FILENAME, which in turn is copied into an array …

JasonHippy 739 Practically a Master Poster

With an IDE you have the convenience of having a lot of things taken care of for you. Any IDE worth its salt should be able to handle any project, regardless of how simple or complex it is. And CodeBlocks is a very good IDE. So IMHO, if you are having problems with it, it's almost certainly something that you haven't got set up correctly (e.g. missing linker settings for 3rd party libraries, missing paths to header files for 3rd party libraries etc.)

But building from the command line can be a good thing. If nothing else, it will at least make you more familiar with the build process, allowing you to better understand/appreciate all of the things that an IDE takes care of for you! :)

Mingw ships with all of the tools you'll need to compile from the command-line and GNU make is one of them. So you don't need to worry about writing long, complex commands on the command line each time you want to build your project (as kvahanyan stated above). You can simply create a makefile for your project and then run make to perform the build process. Many complex projects (past and present) use makefiles with GNU make.

There is an online manual for make here, which is also available to download here.

here is a simple, example makefile. It's for a C program, but it would essentially be the same for a C++ program. The only differences …

Ancient Dragon commented: excellent info +14
JasonHippy 739 Practically a Master Poster

I was just going to say, rather than writing an over-complicated script, would it be simpler to just use a one liner e.g.:
mv ~/Pictures/*.png ~/Pictures/ScreenShots

Or if the files all contain a particular structure to the name. e.g.
ScreenShot-dd-mm-yyyy.png
You could use:
mv ~/Pictures/ScreenShot*.png ~/Pictures/ScreenShots

But it sounds like your instructor has ruled both of those out. I'm not sure what he meant by globbing issues. If you are moving all .png files into the ScreenShots directory, then there isn't really a problem AFAICT. :/

So I guess off the top of my head, you want something like this?:

for files in `ls ~/Pictures/ScreenShot*.png`
do
    mv $files ~/Pictures/ScreenShots/
done

Or perhaps:

for files in `ls ~/Pictures/ | grep "ScreenShot" | grep ".png"`
do
    mv $files ~/Pictures/ScreenShots
done

If there is a particular, set-pattern to the filenames; rather than using two greps like above, you could construct a single regular expression in a call to grep to ensure the entire filename matches the pattern.

I'm not sure either of those examples with the for loop are essentially any different to the one liners I posted above though! :/

JasonHippy 739 Practically a Master Poster

Although, if you use a typedef instead of a macro your original code would work:

#include<stdio.h>

typedef char* CH;
int main()
{
    CH a,b;
    printf("%d %d\n",sizeof(a),sizeof(b));
    return 0;
}

Now we've defined a new type called CH, which is a char*, so now a and b are both of type char*.
Which might be what you were originally aiming for!
Personally, I try to avoid using typedefs as they tend to obfuscate code, making it harder to understand what is going on. But there are certain situations when you might want to use them!

ddanbe commented: Nice +14
JasonHippy 739 Practically a Master Poster

This works, but I wouldn't recommend it! :
#define E MyClass::E
Which would cause the pre-processor to expand any instance of E in the cpp file to MyClass::E.
So you could use:
E(1,2,3) in your code and the pre-processor will expand the macro to MyClass::E(1,2,3)

But the downside is, if you have any instances where the function is called like this:
MyClass::E(1,2,3)
The pre-processor will expand the line to:
MyClass::MyClass::E(1,2,3)

Personally I'd stick to using MyClass::E to call your function, but that's just me! I think using a macro for this is a bad idea!

JasonHippy 739 Practically a Master Poster

The reason you aren't getting what you want out of the command is because you are redirecting the error output from the wc command into time.out. NOT the error output from the time command.
What you need to do is this:

time (wc filename >wc.out) 2> time.out

That will redirect the output from the wc command into a file called wc.out and will redirect the standard error output of the time command to a file called time.out

JasonHippy 739 Practically a Master Poster

I think Gallium refers to this:
https://en.wikipedia.org/wiki/Gallium3D

Perhaps the system information is reporting the driver in use rather than the model name of the card! I don't know if there are any proprietary drivers available for that particular card in Linux (probably not if you can't find any), but the free/open source drivers currently in use on your machine should fully support it.

Personally I don't think there's a problem. Your new card should be able to handle any 3D CAD/CAM type software you throw at it! If you want to be sure, you could perhaps try finding some benchmarking software to test the card in Fedora. Or just install whatever program you want it to run and see how it performs. I think it'll be fine!

JasonHippy 739 Practically a Master Poster

@OP: Thanks and sorry, I've been unable to get online for a few days. Having a manic time at work and at home. Didn't manage to check back after my previous post!
@Mike: Thanks for picking up my slack! Heh heh! :)

Getting back on topic:
Pydoc is used to generate help files from python source code. I don't think its a critical thing to have installed, it shouldn't affect Haizea too much. I guess Haizea's install script must use pydoc to create and install some help files/documentation. Sounds like you don't have pydoc installed, hence the error messages. If you want (or require) the documentation for Haizea, then you'll have to install pydoc and try running Haizea's install script again to allow it to build/install the documentation.

Off the top of my head; To install pydoc in Ubuntu, I think the packages you need to install are called:
python-epydoc
epydoc-doc

The python-epydoc package contains the actual pydoc module for python and epydoc-doc is its documentation package.

In case I haven't remembered the package names correctly, you might want to try running apt-cache search --names-only pydoc to verify their names before installing them with them with sudo apt-get install. Sorry, I haven't got my Linux laptop with me at work today so can't double check for you! :/

Once you've installed pydoc, you can run haizea's install script again and it should build and install the Haizea documentation for you.

Hopefully you can mark this as …

JasonHippy 739 Practically a Master Poster

Oops. I've just realised, in my previous post I was slightly wrong regarding the build errors from your Python compilation.

The errors ARE from when gcc is trying to compile the Python extensions, but they aren't because of missing files in the source-tree, it's more likely that you are missing some of the dependencies required to build the extensions. So you are missing several C/C++ dev packages (header files and libraries) required to build Python.

To solve this problem and to allow Python to build, the following command should do the trick:
sudo apt-get build-dep python
That should download and install all of the dependencies required to build Python 2.7 from the source-code you downloaded and should allow Python to build successfully if that's really what you want to do.

But yet again, I must stress that you absolutely don't need to manually build and install Python at all, it is already installed on your system. The rest of my previous post explains what you should need to do to get Haizea up and running!

To save any confusion, here are the steps again....

1: Install all of the pre-requisite requirements for Haizea:

  • Python (required): You already have Python installed!
  • mxDateTime (required): Use "sudo apt-get install python-egenix-mxdatetime python-egenix-mxdatetime-doc" to install from the Ubuntu repos.
  • Mako support (optional): Use "sudo apt-get install python-mako python-mako-doc" if you want to add mako support
  • Psyco (Optional): Download and manually build/install psyco if you want to use it (see 1st link in previous post)
JasonHippy 739 Practically a Master Poster

OK, all of those messages are from when gcc attempts to build various python extensions/libraries. It would seem that it is unable to locate the files mentioned, so perhaps you don't have all of the source. Not sure what to suggest to fix that.
However, I will reiterate that you already have python 2.7 installed. You do not need to build python from source or install it manually. It is already on your machine and available to you and to any other programs that require it!

From looking at the instructions here:
The pre-requisites are Python 2.5 - So the version you already have pre-installed (2.7) should be fine because all of the 2.x series are backwards compatible with each other.

Then the other requirements, mxDateTime and Mako (optional) are available in the Ubuntu repositories:
Running the command apt-cache search --names-only mxdatetime lists two packages:

python-egenix-mxdatetime - date and time handling routines for Python
python-egenix-mxdatetime-doc - date and time handling routines for Python (documentation)

So to get mxDateTime installed you need to use:
sudo apt-get install python-egenix-mxdatetime python-egenix-mxdatetime-doc

And that's your other main dependency sorted!

A search for mako (which is optional) reveals these packages:

python-mako - fast and lightweight templating for the Python platform
python-mako-doc - documentation for the Mako Python library

So if you want those packages you can install them too!

The final optional dependency, psyco doesn't appear to be available. So you will need to download, build and install …

JasonHippy 739 Practically a Master Poster

I've never used FLTK myself, so I couldn't comment on that. But wxWidgets is pretty straightforward to use. In the past I have ported/converted a couple of C++/MFC based applications on Windows to use wxWidgets and made additional changes to the codebase to allow the program to build on multiple platforms and compilers. So from experience, wxWidgets was relatively painless to use.

QT is another rather good GUI toolkit. I've not used it too much so far, but I'm gradually getting the hang of it!

christinetom commented: helpful anyway. +1
JasonHippy 739 Practically a Master Poster

Lucaci's suggestions are good. I have some additional comments.

If you want to understand why your original/existing code is failing:
Part of your problem is that you are using a single, global stream to deal with file I/O. Another, bigger part of the problem is that you are not closing the files in appropriate places before attempting to open the file again.

Also, when you initialise your global fstream, you are naively assuming that it opened successfully. And in this case, you got lucky, because the file was opening. But because you failed to close the file before attempting to reopen it in read mode in your login code, your openFileIn function was failing!

To prove this, take another look at your code:
When printMainPage is first called in main, the file is already open (or at least it might be... See above!).

If the user selects '1' to register, you are naively assuming that the global fstream object will be open and are then writing to the file.. Which is bad because there is no guarantee that the file opened successfully in the first place. Also, more importantly another mistake you've made is that you are not closing the file until right at the very end of the function.... And I could be wrong, but from looking at your code I don't think the file will ever get closed with the call to close there. That particular area of the code looks unreachable!

To compound things:

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

@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

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

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

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

@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

@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

@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

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

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

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

Actually, the problem is that iostream is a c++ header file. Also namespaces are a c++ thing.
If you are using GCC for C, then you need to #include <stdio.h> for scanf.

If you are trying to compile C++, you need to use g++ not GCC.
You might also want to consider using cin (which is provided by iostream) rather than scanf, which is an old C function which is superceded by C++'s i/o streams implementation.

nmaillet commented: Good +5
JasonHippy 739 Practically a Master Poster

With std::vector, you can do either!
If you know what the vector should contain when your class is instantiated, you can initialise the vector with whatever it needs to contain in your class constructor. Or if you know how many elements it will need to contain, you could initialise it to allocate a fixed amount of space (to avoid reallocations). But vectors are dynamic containers, they are not like ordinary C style arrays. So if you just want your class object to start out with an empty vector, then you can declare it as a member of your class and it will be given a default, empty initialisation and you can populate it on the fly.

Regarding your initialisation problems, if you post a snippet of your code; I'm sure somebody here can steer you in the right direction!

JasonHippy 739 Practically a Master Poster

In my experience the intellisense in VS has always been a bit flaky (assuming you're using VS) and shouldn't be relied upon too heavily! I've been using VS at work since version 6. I'm currently using 2008 and I don't think intellisense has ever worked properly. Very often, the intellisense database that VS uses gets corrupted and doesn't always update properly after making changes to problematic code. But you can usually clear up any problems with intellisense (albeit temporarily) by closing your solution, deleting it's corresponding intellisense database and then reopening the solution. Then the intellisense will rebuild the database and it'll be OK until it corrupts again. Which could be seconds, minutes, hours, days or even weeks later. But is guaranteed to happen at some point!

More importantly, what output does the compiler give when you attempt to compile your program? If you get the same errors when you compile your program, then you know for sure that there's a problem. I wouldn't worry too much about errors thrown up by intellisense. As I said, it's always been a bit flaky and problematic and shouldn't be relied upon too heavily! Granted, in this case, it could be correctly reporting a problem, or it could just be that the intellisense database has corrupted and isn't updating properly!

If I had a penny for every time the intellisense database went screwy over the years, I'd probably be as rich as Bill Gates... Well... OK, probably not! But I'd almost certainly have …

DaveTran commented: Great answer and has helped a C# junkie into the world of C++ +2
JasonHippy 739 Practically a Master Poster

I could be wrong, but I think you just need to open up /etc/network/interfaces (or create it if it doesn't exist) and add the following lines:

auto eth0
iface eth0 inet dhcp
JasonHippy 739 Practically a Master Poster

Ubuntu is based on Debian, so other than the UI (No Unity or Gnome 3 in Debian. Debian 6 uses Gnome 2.6) there aren't really many differences.

The main differences are:

  1. By default, Debian tends to use slightly older, better tested packages. Which pretty much assures a stable and relatively bug-free desktop experience. Whereas Ubuntu tends to use newer, more bleeding edge packages. And because of this Ubuntu is often quite buggy after a new release. But to be fair, any major bugs are usually fixed within a few weeks. Incidentally, in my experience it's worth holding off upgrading your Ubuntu installation until a month or so after any new release to give time for any initial bugs to be fixed by the time you upgrade. :)

  2. Because of Debians free software guidelines, Debian doesn't have any non-free software installed by default. So there is no built-in support for non-free multimedia audio/video codecs, no flashplayer plugin etc. Whereas Ubuntu gives you the option of installing non-free codecs in the installer. So with Debian, if you want to use non-free codecs/software you'd have to install them manually by adding some additional, external repositories to your sources.list.

Despite these minor differences, Debian is great! A really stable OS with a large (if slightly dated) selection of additional software.

Personally I like to use the latest, greatest, bleeding-edge versions of my favourite software. So I was a Ubuntu user from versions 7.10 to 10.10. But I'm not a fan of …

androtheos commented: I completely agree with your motives for moving from Ubuntu, I'm surpised they are sticking with Unity. +0
JasonHippy 739 Practically a Master Poster

Well, take a look at what you're doing there:
bot.y = player.y - bot.y
So if the player is at y=0 and the bot is at y=4: The bot would be moved to y=-4.
So the bot jumps suddenly from a y-pos of 4, to a y-pos of -4.

Lets take another example: If the player is at y=300 and the bot is at y=200: The bot would move to y=100
So the bot is jumping suddenly from one position to another and isn't necessarily going towards the player.

Would it make sense to give the bot/bots a speed property? Then you could use a bit of basic geometry to calculate the distance and the angle to the player object, then rotate the speed by the sine/cosine of the angle to give you the distance to move on each axis. So perhaps something like:

// give the bots a speed they can move at (add it to your bot's class or something)
bot.speed = 5; 

// Calculate the distance and the angle between the bot and the player
var dx:Number = player.x - bot.x;
vay dy:Number = player.y - bot.y;
var angle:Number = Math.atan2(dy,dx);

// Optionally rotate the bot to point towards the player (may or may not apply to your game!)
bot.rotation = angle * 180 / Math.PI;

// move the bot
bot.x += Math.cos(angle) * bot.speed;
bot.y += Math.sin(angle) * bot.speed; 

NOTE: For the sake of convenience I've used 'bot' to represent the …

JasonHippy 739 Practically a Master Poster

From what I can see, any compiler should compile the code, but most should issue a warning about the pointer being uninitialised.

As far as I understand things:
With most compilers, when you declare a pointer and you don't initialise it to point to anything; it will point to an arbitrary memory address. So the pointer could be pointing to anywhere in memory. Then when you assign a value to an address pointed to by the pointer as you have, I'm not sure if that's undefined behaviour or what. (Never really looked that hard at the standard docs!). But in the cases where it actually 'works' (e.g. using g++ or Codeblocks with mingw etc); for example: When you assign the value of 3 to x->a in your code. You're most likely writing over the contents of the arbitrary memory address/addresses pointed to by the pointer. Which is probably more than a little dodgy.

If you initialised the pointer to null where you're declaring it in your code, the code would compile on C::B without warning, but you'd get a seg-fault at runtime (exactly as you're reporting with DevC++). So perhaps DevC++ is automatically setting uninitialised pointers to unll. IDK, but that's one possible explanation for the behaviour you're seeing.

Either way, regardless of the compiler you're using. When declaring pointers you should always either:
A. Assign them to point to null (or 0) if you aren't going to be using them right away.
Or:
B. Assign …