JasonHippy 739 Practically a Master Poster

Seeing as you haven't posted the actual error message, I'm guessing you're getting an error or a warning about the call to scanf_s at line 6.

Basically you don't need the & operator before name.
scanf_s expects a char * to be passed in as the 2nd parameter. And in C, arrays are implicitly pointers. So passing name will suffice, no need for the & operator. Using the & operator there converts the pointer to an incompatible type! char (*)[30]

EDIT: Not too sure I've explained the above paragraph particularly accurately...Sorry, had a few brewskies this evening! :)

JasonHippy 739 Practically a Master Poster

First ensure your package lists are up to date:
sudo apt-get update

Then install VLC:
sudo apt-get install vlc

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've just had another thought about the config errors issue. As pfvar.h is a header for the BSD kernel, I am wondering if this header only applies to the BSD port of tcpdump. So perhaps if the configure script finds pfvar, it will realise that it is a BSD build or something.

Now that you've installed the other missing libraries, does configure succeed despite the error message about pfvar? Or does it completely fail? If it succeeds, you should be able to go ahead and build the program.

JasonHippy 739 Practically a Master Poster

Or not.... From looking inside the package, it doesn't contain that header.... Hmmm, not sure what to suggest! :/

JasonHippy 739 Practically a Master Poster

From taking a quick look at the Fedora package database, I think you might want to consider installing libbsd and libbsd-devel. I have a feeling that they might be the packages you are looking for! :)

JasonHippy 739 Practically a Master Poster

I could be wrong, but it looks like you are missing some developer libraries/headers required to build tcpdump.

You can probably ignore the ac_nonexistent.h error, I think that is just a test used in the configuration script to see how your build environment deals with non-existent headers. But the other errors definitely indicate that you are missing some headers, so you'll need to find and install the appropriate development packages for them using yum.

I don't use any .rpm based distros ATM, so I don't know the exact names of the packages you'll need.
On Debian based systems the dev package for rpc is called something like libtirpc-dev, netdnet is libdnet-dev and smi is libsmi-dev. You should be able to use yum to find and install the appropriate packages using 'tirpc' (or 'rpc'), 'dnet' and 'smi' as search terms.

And I'm not sure about the location of pfvar.h... I think it's a FreeBSD kernel header file. Which in debian based systems is usually in a package called something like kfreebsd-headers-{version number}.

Again, I don't use a .rpm based system, so I couldn't tell you the exact name of the package you'd need to install, but use yum to search for and install any FreeBSD header packages that are available.

Hopefully that will allow the configure step to succeed for your tcpdump build.

JasonHippy 739 Practically a Master Poster

I wouldn't have thought that there is any specific software for the Windows phone on Ubuntu or any other Linux distro.

What is it that you want to do with it?

If you just want to transfer files to/from your phone, have you tried plugging it in via USB?
With most phones, the Ubuntu operating system would typically recognise a phone as an external device and auto-mount the phones SD Card as an external storage device and allow you to transfer the files using a file manager like Nautilus or Dolphin.

I've never owned a Windows phone, so I don't know for sure what happens when you plug one into a linux PC! With Android phones, you plug the phone into your computer via USB and select an option on the phone to allow the connection to the computer before you can access the contents of the phones SD card. And moving files to/from an android phone is extremely simple.

What happens if you plug the phone into your laptop with the file-manager open? Is there any sign from the OS that a device has been connected? Likewise, is there any sign on the phone that it recognises that it's been connected to a computer?

Using a quick bit of google-fu I've also found this which might be of some help! It seems it is possible to connect your phone to your Ubuntu PC, but there are problems when copying certain file-types to the phone. Also the …

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

After you've deleted a record and pressed 'y' to go back to the menu, what happens if you select option "b) List Employee Records"?
Does the list still contain the record you just deleted? (Your screenshot does not show this information)

If so, then you are correct, you have a problem somewhere in your code. :)

Because you haven't posted any code, the only useful advice I can give at the moment is:
1. Run a debug build of your program through a debugger (All IDE's should have some kind of debugger support and if you aren't using an IDE, then you'll need to use something like gdb on the command line)
2. Set a breakpoint in the code which is supposed to deal with deleting a record.
3. When your program hits the breakpoint - step through the code and check the values of all variables and see if you can spot the problem.

Otherwise as Nathan has said; you're going to have to post some source code for your program in order for somebody here to help you further!

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

Hang on, {slaps forehead} I think you've probably got spaces in your filenames, that would cause the errors you're seeing! Not sure what to suggest offhand.... Brain has gone completely blank!

For filenames where there are spaces, the shell will incorrectly interpret the results from the ls command in the for i in statement. So each part of the filename that is separated by a space will be seen as a separate result.

From what you've posted, I'm guessing you have a file in your Pictures directory called Screenshot 2013-07-02 21:14:58.png. In which case in the results from the ls command the shell will see the ~/Pictures/Screenshot, the 2013-07-02 and the 21:14:58.png parts of the filename as three separate results.

I don't usually put spaces in my filenames, so I've never had to get around this problem.. Rubberman might have some ideas! I'll have a bit of a play when I can and will see what I can come up with!

JasonHippy 739 Practically a Master Poster

Really?? How odd! :/
Are you using a different shell like zsh or csh or something?

I'm using the default Bourne Again/bash shell on my Kubuntu 12.04 install, and I normally use Terminator rather than Konsole for my terminal emulator. But this script works for me without any errors on both:

#!/bin/bash

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

if [ $? -eq 0 ]
then
    for i in `ls ~/Pictures/Screenshot*png`
        do
                mv $i ~/Pictures/ScreenShots/
        done
fi

I use a few similar scripts to yours on my machine and the above syntax has never steered me wrong!

JasonHippy 739 Practically a Master Poster

Oh yeah, sorry. I forgot to mention about losing the curly braces around the i variable in your mv command too! oops :/
mv $i /home/garrett/Pictures/ScreenShots/
That should clear that problem up!

JasonHippy 739 Practically a Master Poster

You need to put single backquotes around your ls command:

for i in `ls Screenshot*png`

The backquote character is the character used in the markdown language here on DW to enclose inline code. It is usually on the key at the far left of the top line of numbers (under the F keys). On a UK keyboard it's on the ¬ key. On a US keyboard, it's on the ~ key.

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

In which case: Mark as solved? ;)

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

If you're going to use std::strings then that's absolutely fine! :)

Sorry, when I saw your original code I assumed this was a homework exercise where you were restricted to using C style char arrays. Also I really couldn't remember what parts of the std::library are available in the older Borland compilers!

But if you aren't restricted to using C style strings, then yes; std::string would make far more sense to use if it is available to you! When it comes to C++, the standard library container classes and IO streams etc. should be preferred over their older C equivalents. They can save you from having to write and debug a lot of code and offer a lot of advantages over their C equivalents!

With std::strings you can also copy and/or assign strings directly using the = operator (also called the assignment operator). In other words, you can initialise std::strings in exactly the same way you'd initialise primitive types (bool,float, int etc).
So kinda like this:

studentinfo::studentinfo(string vUID, string CampusID, string studentname, string fathername)
{
    cout<<"Parameterized Contructor is Called"<<endl<<endl;
    VUID = vUID;/*Assigning values to Data Member*/
    campusID = CampusID;/*Assigning values to Data Member*/
    Studentname = studentname;/*Assigning values to Data Member*/
    Fathername = fathername;/*Assigning values to Data Member*/

}

It does exactly the same thing as your code, but it looks a little more natural and expresses what is going on more succinctly than using .assign()!

So, is this part of a homework thing as part of a …

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

Yup, as Moschops has said, it's because your constructor is not initialising anything. Which is what I said in my post in your other thread. You are taking in the four parameters, but you still aren't doing anything with them. You need to use the passed-in parameters to initialise the data members of your class.
Like this:

studentinfo::studentinfo(char* vuid, char* campus_id, char* student_name, char* father_name)
: VUID(vuid),campusID(campus_id), Studentname(student_name), Fathername(father_name) 
{
    cout<<"Parameterized Constructor is Called"<<endl<<endl;
}

Note: The above uses an initialiser list to initialise all of the member variables for the class.
If your compiler does not support using initialiser lists, you could use this instead:

studentinfo::studentinfo(char* vuid, char* campus_id, char* student_name, char* father_name) 
{
    VUID = vuid;
    campusID = campus_id;
    Studentname = student_name;
    Fathername = father_name;

    cout<<"Parameterized Constructor is Called"<<endl<<endl;
}

Note: The code for both of the above versions of the constructor makes me a little twitchy/uncomfortable. Whilst you are using string literals, it's ok to just assign the pointer to point to the string. But if you plan to start getting input from a user to populate the data members of your class, you're going to have to deal with things a little differently. It's been a long while since I did anything with low-level C-style strings in C++ (and even longer since I've used C). I've been using std::string and the other std::library container classes in C++ for so long now, I'm more than a little rusty on this particular …

JasonHippy 739 Practically a Master Poster

One thing that does look highly suspicious is that you are deleting pointers to objects that are on the stack... Which is definitely wrong. You aren't using new anywhere in your program and if you didn't use new to allocate the memory, then you shouldn't be attempting to delete it!

JasonHippy 739 Practically a Master Poster

It's all down to the order in which things were being declared and used. Some things were being used in the code before they had been declared.

The following compiles, but crashes at runtime. I'll leave you to debug it!
All I did was move the declarations for the System class and the Packet struct up a bit!:

#include <string>
#include <iostream>
#include <vector>
#include <Windows.h>

using namespace std;

#define DEBUG true
/*
SAPA developmental classes and process
to demonstrate class and functioning 
/thread conjunctions

*/

//definitions
typedef unsigned int UINT;
enum{second, minute, hour};
#define EXITSAPA        100
#define SECOND          200
#define MINUTE          201
#define HOUR            202
#define MakeNewThread   300
namespace sapa{


    struct SubPacket{
        UINT signal;
        vector <string> target;
        vector <string> t_data;
        vector <double> data;
    };
    struct Base_thread_data{//for hardcode handles
        int m_id;
    };
    struct thread_data{//for enumerated handles
        int m_id;
        thread_data(int id) : m_id(id){}
    };

    class System{//holds information for program operation
    public:
        bool quit;
        System(){
            quit=false;
            TimeElapsed=0;
        }

        UINT TimeElapsed;//seconds passed since program run

        int Threads;//number of user threads running
        vector <int> ThreadIDs;//holds the ids of all running threads so none are duplicated and old exited ids can be recycled
    };

    struct Packet{
        System*sys;
        UINT signal;
        vector <string> target;
        vector <string> t_data;
        vector <double> data;
        Packet():sys(){sys=NULL;}
    };

    namespace SystemFunctions{
        void SAPAEXIT(Packet input){
            input.sys->quit=true;

        }
        void NewThread(Packet input){//create new thread and run instructions
            //information on occurence
            UINT TimeTemp=0;
            UINT Period=0;//time needed to elpse in order to run
            while (!input.sys->quit){


            }
        }
        void UpdataTimeSeconds(Packet input){
            input.sys->TimeElapsed++;
        }
    }
    class ConsoleIO{
        string raw; …
JasonHippy 739 Practically a Master Poster

If you had posted the exact errors you were getting from the compiler we could pinpoint problems more quickly!

As you haven't posted any error messages; other than what Moschops has spotted, I can see only one other thing that could cause the compiler to throw an error:

At line 72 you are relying on a default constructor when you instantiate your studentinfo class, but because you have already defined a non-default constructor, no default constructor will be defined by the compiler - At least, this would be the case in a modern compiler. Not sure if that is the case with your old Borland one.
wikipedia backs me up on this! :)

If some constructors are defined, but they are all non-default, the compiler will not implicitly define a default constructor. Hence, a default constructor may not exist for a class.

So line 72 could also be problematic!
If you are getting an error about no default constructor, you either need to create a default constructor yourself, or pass the constructor some parameters at line 72!

Other than that, there are a few other errors in your code. Not syntax errors that will cause compilation to fail. More like logical/conceptual errors really:

  1. Your existing constructor takes four parameters, yet uses none of them. Instead you are using string literals to initialise the members of the class. Perhaps remove the arguments and make this the default-no args constructor until you are ready to implement further …

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

@Rubberman: True, yum and yast are far more convenient for maintaining rpm based systems. I meant to mention them in my previous post. But I ran out of time, so I posted what I had. After all, it seemed to answer the OPs question...ish! Heh heh! :)

When I ran last ran Fedora (back when I first started using Linux), I only ever used the rpm command when I had to manually install a package I'd downloaded from elsewhere. The rest of the time I used yum like any other sane person would! I imagine trying to use nothing but rpm for package management would be a nightmare! XD

BTW: I think yast stands for 'Yet Another Setup Tool'... Something like that!

JasonHippy 739 Practically a Master Poster

The rpm command is the Red-Hat Package Manager - the package management system used by Red-Hat Enterprise Linux, Fedora, CentOS, OpenSuse and many other GNU/Linux distros.
rpm is used to build, install, update, query and/or remove software packages which are packaged in Red-Hats .rpm format.

I have to admit, I mainly use debian based distros which use the debian .deb package format (or Arch, which has it's own package format). I haven't used any distros which use rpm for a few years, so I'm a little rusty with the rpm command myself!

But there's a handy cheat-sheet for using rpm here:
http://www.cyberciti.biz/howto/question/linux/linux-rpm-cheat-sheet.php

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

By default, Ubuntu has Python pre-installed. And the last few versions of the *buntu family of distros use Python 2.7. So Python should already be available to you.

My current Kubuntu 12.04 LTS install reports Python version 2.7.3 installed.
And I don't imagine that there will be any critical differences between versions 2.7.3 and 2.7.5, so I wouldn't imagine that having 2.7.5 would be a pre-requisite. Any version of 2.7 would probably suffice.

So Python is pre-installed in Ubuntu. And if you need any additional python libraries/bindings, then you can search for them using apt-cache search xxx (where xxx is your search term)and install them using sudo apt-get install xxx (where xxx is the package name). With apt-cache search, if you pass the --names-only parameter/option, you will only see results with the search term in the package name (giving you a much shorter, more relevant list of results), otherwise you will see results which also have the search term in the package description.

In your original post, you mentioned that you wanted to install Python to complete the installation of another program. But which program are you trying to build/install? And can you post some more details on the errors that you are getting? That might shed more light on the problem.

From what I can see, nothing that you have posted indicates that Python (or a lack of) is the cause of the problem. The error you've posted is with regard to a missing file or folder which …

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

Other than OpenMP (as mentioned by Moschops), another cross-platform library that immediately springs to mind is Intels Threading Building Blocks (TBB) library.

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

Looking at your code, I guess you just need to alter formattedCmd and formattedUrl to take temf as an additional parameter so you can add the parameter to the generated URL.
So perhaps something like this?

import getopt
import sys
import hmac
import hashlib
import base64
import urllib


def formattedCmd(api, cmd, temf):
    s = 'apiKey=' + api + '&' + cmd + '?' + temf
                # I don't know if this ^ should be ? or & or another character.
                # I'll leave you to work this out!
    return s


def encypt(string, key):
    h = hmac.new(key, string, hashlib.sha1)
    #  print '\n' + h.digest()
    return base64.b64encode(h.digest())


def formattedUrl(baseUrl, api, cmd, temf, signature):
    url = baseUrl + '?' + formattedCmd(api, cmd, temf) + '&' + urllib.urlencode({'signature': signature})
    return url


def main():
    print 'ffffffffffffffffffffffffff'
    try:
        print getopt.getopt(sys.argv[1:], 'u:a:s:', ['help', 'output='])
        opts, args = getopt.getopt(sys.argv[1:], 'u:a:s:', ['help', 'output='])
        print opts, args,'print'
    except getopt.GetoptError, err:
        print str(err)
        sys.exit(2)

    baseUrl = 'http://10.176.14.26:8080/client/api'

    cmd = 'command=listTemplates'   
    temf= 'templatefilter=featured'
    api = 'Qo9Qwfatwz9ARB328Btn9PftzL2Cf5LOWd8OFyJmiM513tpTIm-zKxJoWkWqf353Df397xcLdKXGk8_JO8nM3Q'
    secret = '-kgkBuBUrGFeIC4gUvngSK_3Ypmi7fuF8XdVXIusnyyiEP2YUcG3FnPUGJGy3rp3Bw5ZNnqgS-9tIfyV1QnK1g'

    for o, a in opts:
        if o == '-u':
            cmd = a
        elif o == '-a':
            api = a
        elif o == '-s':
            secret = a
        else:
            assert False, 'unhandled option'

    newCmd = formattedCmd(api, cmd, temf).lower()
    signature = encypt(newCmd, secret)
    url = formattedUrl(baseUrl, api, cmd, temf, signature)

    print '\n' + url

if __name__ == '__main__':
    main()

Is that what you were hoping to do?
In the above, the filter is appended to the URL immediately after the …

JasonHippy 739 Practically a Master Poster

To clarify Moschops and Ancient Dragons comments, let's take another look at your original code:

sample *e;
e = &e;

The line sample *e; declares a variable called 'e' which is a pointer to a sample object, so its type is sample*.
At this point the pointer is uninitialised and points to invalid memory (Which is kinda bad, pointers should really be initialised to null if you are not going to assign them to anything straight away!).
The variable 'e' is NOT an instance of the sample class, it is a pointer to an instance of the sample class. But again, at this point it does not point to anything valid.

Then in the next line:
e = &e; You are trying to assign the pointer to point to its own address.
The right hand side of the assignment operator (=) expects a pointer to (or the address of) a valid instance of the sample class to be passed (a sample*). But instead, it is getting the address of itself ('e').

Now remembering that the type of e is sample*, by passing &e to to the assignment operator, effectively you are passing a pointer to a pointer to a sample object (sample**).
So because what you are passing (sample**) is not what the compiler is expecting (sample*), you are getting a warning/error!

Now compare that to Ancient Dragons entirely correct code suggestion:

sample s; // an object of type sample
sample *e; // …
JasonHippy 739 Practically a Master Poster

The reason you are seeing strange values is because in your SetData function you are doing things backwards, you should be doing this:

a=x;
b=y;

NOT this:

x=a;
y=b;

To explain why you are seeing seemingly random values:
In your original code, you are passing the values x and y into your classes SetData function. At this point, the a and b members of the class are uninitialised; they haven't explicitly been given values, so they hold arbitrary/random values. Then your are assigning the passed in variables x and y whatever values are held in variables a and b (which are both uninitialised). So effectively you are just changing the passed in values and are not changing the values of a and b (which is what you want to be doing). Then when you call your print function, you are seeing the sum of the two arbitrary values.
I hope that clears things up for you!

JasonHippy 739 Practically a Master Poster

Alongside the missing braces mentioned by Nichito there are a few other problems in your existing code:
Your one dimensional char array 'name' will only hold a single name up to 19 characters long (the final place in the array should be reserved for a null!). 'name' will not hold multiple names. So you have a problem right there. Your code to get the users names will not work in the way that you think it does.

As this is C++, either use an array or a std::vector of std::strings to store all of the students names. Otherwise, if you haven't covered using std::library containers and/or you are only allowed to char arrays, you'll need to use a 2 dimensional char array to store all of the student names.

Then there is your array called num (which is where you're hoping to store students scores) which is a one dimensional array and has a hard-coded size of 5. The reason you are only seeing one set of scores is because your array of scores (num) is completely over-written each time through the nested for loop inside the first for loop in your code. So at the end of the program you will only see the last students results. You need to use a two dimensional array in order to store all of the students scores.

An additional problem with your existing code for getting the students scores is that it is possible that a user could enter a number …

JasonHippy 739 Practically a Master Poster

Ooops! Yes, you're right Tony... I stand corrected. :) Not sure how I missed that little detail... :/
Looks like I should have gone to specsavers, heh heh! XD

And I agree, there are probably several more interesting uses for the collected statistics on the generated numbers, but I stand by my original statement. My point was merely that the original code is not junk as stated by some of the earlier posters in the thread. It has a purpose, even if that purpose is somewhat limited in scope in terms of its usefulness!

JasonHippy 739 Practically a Master Poster

The code isn't nonsense at all. It is generating a random number (between 0 and 1000) of random numbers (between 0 and 500) and storing statistics in a dictionary on how many times each number is generated.

First it determines how many numbers to generate by selecting a random number between 0 and 1000.

Then in the first for loop, value is assigned a random number between 0 and 500.
So as an example, on an iteration of the loop the number 497 is randomly generated.

As far as I understand it, the line: stats.setdefault(value, 0)
Will generate a key/value pair in the dictionary where 'value' is the key and 0 is the default value for the pair (so if the key/value pair does not already exist, it will be added to the dictionary and given a default value of 0). The final line in the first for loop increments the value of the key/value pair at stats[value] by 1.

So going back to the example using 497 as the generated number:
Assuming this is the first time that 497 is generated, the key/value pair 497,0 is added to the dictionary. So 497 is the key and 0 is the value. Then the value of the pair is incremented by 1. So 497 is the key and 1 is the value.

Any subsequent time the number 497 is randomly generated, setdefault will do nothing (because the key/value pair already exists in the dictionary) and the value part …

JasonHippy 739 Practically a Master Poster

OK, sounds like it could be a DNS related issue.
This thread in the official kali forum might help you:
http://www.kalilinux.net/community/threads/installing-packages.61/

In it, the OP reports being unable to install any packages from the official repos via apt.
Turns out their DNS settings were causing the problem. Some way down the first page the OP posts the following as the solution to their problem:

Ok we have success,done a bit of googling and found some info on editing the etc/resolv.conf file. Changed the nameserver from my routers default address to googles 8.8.8.8,ran commands and hey presto we have lift off.. Thanks for everything...

So checking/changing your DNS settings might solve your problem!

JasonHippy 739 Practically a Master Poster

First up, you've posted in the wrong forum. You've posted C++ code in the C forum, heh heh!

Anyway, as you are dealing with whole hours, you might want to consider making hours an int. Also, to take into account somebody parking for a fraction of an hour you should use std::ceil in your calculation.

So for example 490 minutes equates to 8.16667 hours, std::ceil will round this value up to 9.0. So they will be charged for 9 hours rather than 8.
Likewise, if the user entered 20 minutes, std::ceil will round that up to 1.00, so they get charged for 1 hour.

So perhaps for your calculation for the number of hours parked:
int hoursParked = static_cast<int>(std::ceil(minutes/60));
In the above we use std::ceil to round-up the value of minutes/60 and we use a C++ static cast to cast the value from float to int.
Note: std::ceil requires you to #include <cmath>

Also your variables hours1, hours2 and hours3 are badly named as they do not describe the values they contain. These variables do not store hours, they store the rates at which hours of parking are charged. So personally I would call them rate1, rate2 and rate3.

As for calculating the cost of parking, your calculations are simply wrong!
As your code stands, if a user was parked for between 4 and 8 hours they would only be charged for 4 hours.
Likewise, if a user was parked for anything over 8 hours, …

JasonHippy 739 Practically a Master Poster

I don't know what compiler you're using, but from running your code through visual studio, your program initially seems to be doing what it should. The functions called in dummy_method seem to be working. For me, the fprintf call at the end of main displays check:_test answer with some additional gibberish characters on the following line.

At first I thought the reason for the gibberish characters might have been due to strings that were not null terminated. But from looking at your code a little more carefully, I'm pretty certain that the problem is in the way you are dealing with the input strings and creating your new nodes.

In dummy_method, you have declared two local variables ques and ans to act as buffers to store the users input. Then in your call to make_question_answer3 you are passing in pointers to both of these variables. In turn, inside make_question_answer3; in your calls to getnew you are passing the pointers again (in two separate calls). Finally in both calls to getnew, the new nodes char* member variables (guess) are assigned the passed in pointers.

So effectively, you are creating two new nodes and the guess member variables of both are set to point to the addresses of ques and ans respectively. Now the thing to bear in mind is that the ques and ans variables being pointed to by the guess variables of both nodes are local to dummy_method. So after your call to make_question_answer3 returns and we are back in …