Freaky_Chris 299 Master Poster

simplest method is to do something like this

cin.ignore ( 80, '\n' );
cin.get()

The reason cin.get() appear to be skipped is that it reads one character from the input stream.

After calling cin >> you find that at least the '\n' character is left in the inputstream. Thus cin.get() will read this as requested which then leaves you a clean inputstream. In this case calling cin.get() again solves the problem.

Chris

Freaky_Chris 299 Master Poster

system("pause");
is not really adviseable.
cin.get() is doing it's job just fine... unfortunately it's all a little complex. There is a sticky at the top of the C++ forum Called "How do i flush the input buffer"...it may all seem a little confusing but never the less it's worth the read.

One quick solution is cin.get(); cin.get(); just call it twice you can also go down the line of cin.ignore() and many other methods all discused in that the thread>

Chris

Freaky_Chris 299 Master Poster

and use cin.get();

to pause so you can see the result

use return 0;

Chris

Freaky_Chris 299 Master Poster

Long story short, because standards have changed since the days of Turbo C++ and also the compiler also does some work automatically for you sometimes.

(btw if the thread is solved don't forget to mark it as solved)

Chris

Freaky_Chris 299 Master Poster

Then you would of tried and then realized it wasn't possible or failed trying and asked for help and someone would of helped you out. Either way it would of been a learning experience even if it wasn't possible.

Chris

Freaky_Chris 299 Master Poster

You could call,

myFile.seekg(0, ios::beg);

P.S. If your problem is solved please mark the thread as solved

Thanks,
Chris

Freaky_Chris 299 Master Poster

@singhraghav
1) Don't Hijack threads - Start your own (we much much prefer it)
2) After 13 posts you are expect to now how to use code tags
(read this)

Follow that advise and you will get some help.

Thanks,
Chris

Freaky_Chris 299 Master Poster

Note there is also no such thing as this #include<stdio>
it should be csdtio....
but you can ditch that if you change getch() to cin.get()

Please don't blame a compiler/IDE for your mistakes.

By the way Dev-Cpp is dead IDE. It's advised you swap to Visual C++ (express 2008 its free) or Code::Blocks

Chris

Freaky_Chris 299 Master Poster

Then it should be

ifstream myFile("rawDictionary2");

So it is actually a file object rather than a string object!

Chris

Freaky_Chris 299 Master Poster

i believe i told you that it is because you are declairing variables in the function call......

Freaky_Chris 299 Master Poster

Other than the fact there is no case 1, then i dont think so....plus im not to sure what case 'ID' is suppose to be...in fact i have no idea.

Chris

Freaky_Chris 299 Master Poster

Thats because you are declaring variables in the function call....
Chris

Freaky_Chris 299 Master Poster

If you want us to comment on your sort code, simple past the sort code and thats it.

this is the pseudocode for a bubble sort

procedure bubbleSort( A : list of sortable items ) defined as:
  do
    swapped := false
    for each i in 0 to length(A) - 2 inclusive do:
      if A[ i ] > A[ i + 1 ] then
        swap( A[ i ], A[ i + 1 ] )
        swapped := true
      end if
    end for
  while swapped
end procedure

Compare it with what you have does it look right to you?

The other suggestion was a selection sort
Perhaps that will help you along.

Chris

Freaky_Chris 299 Master Poster

Thats because total is never initialized to 0. So you start with a random number from somewhere in the CPU's memory then start incrementing it by 1. This is bad! very bad!

Chris

Freaky_Chris 299 Master Poster

Something like daniweb is a forum mainly, i doubt you will make your own forum more just build of a forum host, try googling Forum Hosting it should turn up some good results.

Chris

Freaky_Chris 299 Master Poster

A homepage for a website?
If so you should look into HTML/XHTML aswell as things like PHP Javascript...You may find this site helpful
http://www.w3schools.com/

p.s if this guess was right your in the wrong forum :D

If not a website i'm confused by your question.

Chris

Freaky_Chris 299 Master Poster

Please don't tag other questions onto the end of exsisting threads.
If the original problem is solved please mark this thread as solved and start a new topic (if nessasery).
This is probably the best:
http://www.microsoft.com/express/download/#webInstall
Mircosoft's Visual C++ Express 2008 (if your on windows)

Or you could use Code::Blocks
http://www.codeblocks.org/

Thanks,
Chris

Freaky_Chris 299 Master Poster

please use code tags, and avoid red text many people will be repelled by it!

define IS_STRING 1
define IS_CHARACTER 2
define IS_INTEGER 3
define IS_FLOAT 4

This is to make a it easy for you to understand, basically writing IS_STRING is exactly the same as writing 1.

bool DotReached=false;

Create a boolean value can have the value of true or false

if(Input.length()==1 && (Input[0]>'9' || Input[0]<'0'))

Checks to see if the input is only one char long, if so checks thats its bewteen 0 and 9. Otherwise it must be a Char, cannot be a floating point. If it is between 0 and 9 then it is a integer.

if((Input[x]>'9' || Input[x]<'0') && Input[x]!='.')
{input_type=IS_STRING; break;}

Checks to see if the character is between 0-9 or is a '.' if not then its a string and breaks the loop since we have no reason to carry on.

{if(!DotReached) DotReached=ture; else
{input_type=IS_STRING; break;}

Checks to see if Dotreached has been set, if it has and we are at this point again then we know its a string. If it hasn't then it could still be a floating point.

Chris

ninja_gs commented: Thk Yu Chris........U r Kind Enough to teach me.......I m Happy ....... +1
Freaky_Chris 299 Master Poster

If thast all mark as solved please

Chris

Freaky_Chris 299 Master Poster

You should double backslash \\

Chris

Freaky_Chris 299 Master Poster

There's a stray bracket in your while loop, also i think you should be using doubles not ints...

Chris

Freaky_Chris 299 Master Poster

Make the delay bigger, thats the idea behind wx.media.MEDIA_LOADED event it triggers when the media is loaded and only then, unfortunately it seems poorly documented.

Chris

Freaky_Chris 299 Master Poster

It's ok, if thats everything mark as solved please

Chris

Freaky_Chris 299 Master Poster

i may have over complicated it for you :lol: my apologise. Ofcourse this is depending on whether or not you have the array in the class as private or public. if it is private then ok you need to go down the operator route, if its public then you can use class.arrayname[][] as normal.

Freaky_Chris 299 Master Poster

You need to look into operators,
You may find this useful
http://www.cs.caltech.edu/courses/cs11/material/cpp/donnie/cpp-ops.html

Chris

StuXYZ commented: Excellent link! +1
Freaky_Chris 299 Master Poster

OK, here is my sugestion...please bare in mind i know nothing about Python GUI and event handling so i cannot really provide any sort of code examples.

You need to ensure that the media has loaded correctly before you can play it. So the best way to doing this is to play the sound inside the wx.media.EVT_MEDIA_LOADED event.

Hope that makes sense to you
Chris

Freaky_Chris 299 Master Poster

Indeed, this statement is like a an if statment its equivelent would look something like this.

string myIF(int a){
    if(a > 0){
        return ", ";
    }else{
        return " ";
    }
}

Hope that makes sense
Chris

sid78669 commented: Superbly Explained!! +1
Freaky_Chris 299 Master Poster

There shouldn't be a problem here... i just created a simple program to open a file that contains some text in exactly the same mode as you, and called seekg(0, ios::beg) without a problem...

you could always try calling f.clear() before hand...

Chris

Freaky_Chris 299 Master Poster

Thats because the stack will be empty so you need to check stack.isEmptyStack(), if its empty break out because its unbalanced, if its not empty continue on and check.

Chris

Freaky_Chris 299 Master Poster

Not too basd, the reason is this code here

if(exp[x] == stack.top())
{
	stack.pop();
}

This should be a comparison to the opposite of stack.top() for example you are comparing like this -> ']' == '[' which will never be true. You will need to check that the brace type is the same and is opposite to the one of the top of the stack, if thats true then pop. if it isn't true, then break out of your loop since it is unbalanced.

Chris

Freaky_Chris 299 Master Poster

This is a common problem, it seems you have to manually include the mail module, this link maybe of help to you
http://stackoverflow.com/questions/169897/how-to-package-twisted-program-with-py2exe

Also another suggestion rather than py2exe use bbfreeze
http://pypi.python.org/pypi/bbfreeze/0.95.4

Chris

Freaky_Chris 299 Master Poster

This is easy.... Count
If you get below zero then you have failed,
and if you get not-zero at the end you have failed.
You might want to check scope bridges. I.e.
(a{b+c)} which I would pass as fail.
but that is easy to modify the code below to include.

Example of pseudo code for JUST ( and ).

string A = "(expession) with ) ( ";
int b(0);
for(int i=0;i<A.length();i++)
 {
   if (A[i]=='(') b++;
   if (A[i]==')') 
     {
       b--;
       if (b<0) failed();
     }
} 

if (b!=0) failed();
success();

Additionally, I am sorry BUT you cannot use boolean values as suggested by freaky_chris since
the expression ((x+y)) would fail. And that is not acceptable.

ooh, valid point. I hadn't though about that one i do apologise...
Chris

Freaky_Chris 299 Master Poster

loop throught all the elements on the stack, check what it is either ()[]{} and use 3 different boolean values, 1 for each brace type ie 1 for () 1 for [] and 1 for {}. then toggle states...if that makes sense and if the state wouldn't chage then you know they are not balanced.

That was poorly worded i think sorry :(

Chris

Freaky_Chris 299 Master Poster

you need to add the & on the function declaration and definition

Chris

Freaky_Chris 299 Master Poster

Hmm quick suggestion probably a crazy one :D does this work

static void Test2(list &tester)

Freaky_Chris 299 Master Poster

If you zip the file then you should be able to sen it with no problems. The other user will just need to unzip the file and then run the exe

Or you cuold go down the root of changing the extension

Chris

Freaky_Chris 299 Master Poster
string myString;
getline(cin, myString);

Chris

Freaky_Chris 299 Master Poster

Yep, that works a charm. I tried something simillar before but it didnt work. Oh well, that all works now, thanks Chris!

Hehe glad you got it working.

To think i've only ever downloaded wxPython & created a basic window with a listbox on it. I've never even added data to that list box hehe. Ah well it's all good fun.

P.S Mark as solved xD

Chris

Freaky_Chris 299 Master Poster

Hmm thats odd. I did think about the SendKeys module but i wasn't sure if you wanted to use it or not.

Addressing your other issue, did you try using self.textCtrl2.SetInsertionPoint(self.textCtrl2.GetLastPosition()+1) , i cannot say as i've tried it but that should theoretically force it to scroll to the bottom.

Chris

lllllIllIlllI commented: Thanks for that +1
Freaky_Chris 299 Master Poster

Hmm i see your point, i cannot find a method of creating a wxKeyEvent event which is what is required for EmulateKeyPress().

Another possible solution would be to use

self.textCrtl.SetInsertionPoint(0)

Or you could use this method to clear the textcontrol which should work perfectly

self.textCtrl.Remove(0, self.textCtrl.GetLastPosition()+1)

Hope that helps

Chris

Freaky_Chris 299 Master Poster

Could you use EmulateKeyPress() after that to send a backspace to it?

Chris

Freaky_Chris 299 Master Poster

Yes there is it's pretty simple too

mylist = ['blue', 'red', 'green', 'green', 'red', 'red']

for word in set(mylist):
    print word, "appears", mylist.count(word), "times."

Hope that helps.

Chris

Freaky_Chris 299 Master Poster

oh..thx guys.....but i still cant do it....need some beginning codes...as u know im still beginner....well..hope u can help me thx!!

You are NOT going to get a code solution. Either give in trying or post what you think you should be doing in words, pseudo-code or some method of displaying what you think you have to do. Then we can help you from there.

@everyone else
Hmm this makes interesting reading thanks

Chris

Freaky_Chris 299 Master Poster

create a list of which characters have been hinted and check the new hint doesn't match any of the previous.

You can also limit people to X amounts of hints too

Chris

Freaky_Chris 299 Master Poster

What exactly do you mean by 'at the top'?

Chris

Freaky_Chris 299 Master Poster

call me silly but why not just send the data straight to the correct file name. Also i would recomend you do all file copying in binary mode to prevent loss of any data.

Chris

Freaky_Chris 299 Master Poster

VC++ Use "CLR" Which is managed code, using MFC wrappings etc. But it does support ISO / ANSI Standards well and is a good compiler.


Grr i hate to think of Dev being dead can everyone stop pointing it out lol

Chris

Freaky_Chris 299 Master Poster

The installation of the current beta isn't as good as it should be, at the moment.
You must uninstall all past versions, to be safe, you must use the default {drive}:\Dev-Cpp\ (at least on the XP installations, I've noted), make sure it's not dir Dev-C++ like from the older versions; on Vista make sure you have full admin privileges to install(maybe even to compile).

edit:
And note: It's in beta, so you may find a minor inconveniences, here-and-there.

I never have such problems, i've install Dev just about everywhere including onto pen drives. Also Vista doesn't require admin to run or anything like that. I simpley thing he didn't install the compiler only the IDE

Freaky_Chris 299 Master Poster

Post all of your code & all of the error log please

Chris

Freaky_Chris 299 Master Poster

This should help you out

http://msdn.microsoft.com/en-us/library/bf7fwze1(VS.80).aspx
I would read that but this is how to use it anyway

#include <string>
#include <direct.h>

using namespace std;

int main(void){
    
    string hello;
    
    hello = "C:\\";
    
    _chdir(hello.c_str());
    
    cin.get();
    return 0;
    }

Chris