Before you do the above, migrate to the C forum
Chris
Before you do the above, migrate to the C forum
Chris
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
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
Yer thats normally the case, every programmer i know gets rusty after not using something for a short period of time.
I've breifly looked into threads whilst i was developing a chat application and no i don't think they are too complex, once you have your base class set up. Which is not too difficult nor complicated.
You may find these links helpful
http://www.devshed.com/c/a/Python/Basic-Threading-in-Python/3/
http://www.python.org/doc/2.5.2/lib/module-threading.html
http://effbot.org/librarybook/threading.htm
ftp://ftp.fzu.cz/pub/unix/python/lib/module-mutex.html
Chris
This looks to me like you are going to be going into threads and mutex. You should have a good look on google on how to use threads.
You could spawn a new thread to control the Opponents attacks, since they require no user imput all that would be happening is one thread is sitting waiting for the user to type something in whilst the other constantly modifies some variable such as the players HP. Which is where MUTEX comes in. Becuase there is a chance that the user will input data at the same time as the opponent tries to attack you may be trying to access the same variable at the same time...but with mutex locks that is easily fixed.
The best part about this is, lets say as you progress through the game you wanted to face 2 or 3 opponents. It should be easy enough to control this as you can just spawn another thread which attacks the user.
Note you can use some for of sleep to wait inbetween each of the opponents attacks.
I hope this information has been helpful to you.
BTW: Excellent first post, other users should read and learn from this
Chris
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
Could you use EmulateKeyPress() after that to send a backspace to it?
Chris
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
I personally would use a string...
#include <string>
.....
string myString;
cout << "Enter a number\n>>";
getline(cin, myStrnig);
And then you may want to readinto the cctype header, which will give you some useful functions like isdigit().
Chris
Infraction did say it was a rough idea, not the exact code to use. Also the ifstream takes C Strings, the function c_str() isfound in the string header and converts string object to C Strings, incase you were not aware of this.
Chris
I suggest having a read about this
and looking over this
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
int main(void){
string a = "3";
int b = 12;
int answer = 0;
answer = strtol (a.c_str(), NULL, 10) + b;
cout << answer;
cin.get();
return 0;
}
Chris
With that code, I'm pretty sure your program is adding the char to the char array holding the answer(please someone correct me if I'm wrong), you will have to convert the chars to numbers and add the two from there. atoi(const char) will convert a char or char array to an int. It is included in iostream.
Although i made a suggestion about strtol() and strtod(), Which are much better than atoi()...you should read some comparisons about strtol() and atoi() you will soon realise why we no longer use atoi()
Chris
I think that the problem is that section is a char array and you have
the problem that you have to convert them to integers first, otherwise they have their ascii value. e.g. 1 is 49 (I think)So isolate the number part of section and convert to an integer/double and then add.
however, all of that is a guess, you will need to post a little more code, in particular the type definitions of track, section and answer. Additionally,
while you are looking at it does track become to big... i.e. bigger than the array section?
As an extention to this assumption, i want to add the following. Indeed the ascii Value '1' has the numerical value 49. Thus we are given a way to convert a character to its numerical value, by subtracting 48 or '0'.
However this will not solve all of your problems. You may find that strtol() & strtod() are helpful in what you are looking for (sting header) you may find that a more practical solution is to use stringstreams.
If you want more info on these just ask, but i would recomend having a read from google links. And also search Daniweb for string/char to int conversion.
Chris
When you say you have successfully assembled it, i'm asuming you now have at least one Object file. In which case you need a linker to link the object files together into and exe file.
Chris
Before you take a tutorial in dreamweaver which is a very good choice. I would reccomend learning how to post a question. For starters this is a web design question NOT a Java Programming Question. So why is it in the Java Topic?
I would also reccomend that you have a look at some other stuff so you know what your doing. As to how you are going to get your website online. What xHTML & CSS are, and how they are used as well as drawing out a basic outline of your web site design before you start trying to create it.
Chris
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
to seed the random number with srand the *best* method is as follow.
#include <ctime>
...
srand(time(NULL));
Note you only need to seed rand once in your program.
Chris
The logic behind the memory is not too complex. At the start of the game Create a list containing all of the sequence. And then compare the button press with the value in the correct list position. for example the first button press should be equal to the value stored in yourlist[0]. and so on, if its a match then they are correct...and so on
Chris
You need to tell your Compiler/Linker to include them in your project
Chris
Your gonna need to provide alot more information. For example what are you programming exactly..some kind of mirco controller. Each micro controller is different and the dll file you have been given will vary for each also. So it is not so much a C++ question. It is more a question about the dll you have been provided with. I would suggest search for a forum that specifies in working with the particular chip you are dealing with. You will probably get better answers. Either way that information you have given is inadequate.
Chris
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
Have you ever read about strtok?
http://www.cplusplus.com/reference/clibrary/cstring/strtok.html
Chris
Java-o-matic has some video tutorials, not much though
Chris
2. Ok will change code to that, not much difference - doesn't eof check if there is a line available? So its just doing the same (I could be wrong)
EOF can return true for more than that reason i.e certain characters can cause it to return true. I believe '\v' is one of those. This is why it should be avoided.
Chris
What exactly do you mean by 'at the top'?
Chris
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
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
I'm aware of that arctick wolf. But i was going down the lines of what Colin said. My fault for missing the bit that it must be done on PC. Sorry.
Chris
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
Post all of your code & all of the error log please
Chris
Having an ascii game that uses a GUI inventory just screams confused at me.
Chris
What i saying is, Can you not make your own oscillator to controll timing?
Chris
could you not use a Hardware clock to do the timing for you?
Chris
What method are you using to store your board then?
Chris
You really need to get your head around the logic, lets say (since im guessing you are using a 2d array for your board) your board is arrange something like this small scale
- - - - -
- - - - -
- O - - -
x O - - -
x O - - -
the line of 3 'O' would be in the array as board[1][x] where x is the height, so loop through it see if there are 3 in a row is so block it, if it is a valid move.
assuming O is player x is compuer in that example
Chris
Spawn a thread to count two seconds, after that make your tread force '\n' into the keyboard buffer and there you go
Chris
Nobody will do your homework for you.
Post some example code and your problem and we will happily help.
Chris
If you have to implement a quicksort, then i suggest you do. Have a read
http://en.wikipedia.org/wiki/Quicksort
It must save to compile, i know a 36 year old doing a java programming course...he has homework
Start of by giving us an example of your code. So we can see where you are going wrong. Also pointing us to the bit you think is the problem would be good.
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
return (str[29]);
but no use still errors
thats a char your returning, still not a char array.
Considering the given code as an algorithm calculate the time complexity of this code.
#include<iostream>
#include<stdlib.h>
using namespace std;int main(){
int i, j, n;
for(i=0;i<n; i++){for(j=0; j<n; j++){
cout<<"my time complexity is = "<<i*j<<endl;
}
cout<<"complexity is increasing"<<j<<endl;
}
system("pause");
return 0;
}
Code tags please
[/[TEX]][/TEX]code]. Also if our asking what the time complexity is. Why don't you consider showing us what you understand before we just tell you.
Also it should be cstdlib, since this is cplusplus
[CODE=cplusplus]#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
int i, j, n;
for(i=0;i<n; i++){
for(j=0; j<n; j++){
cout<<"my time complexity is = "<<i*j<<endl;
}
cout<<"complexity is increasing"<<j<<endl;
}
system("pause");
return 0;
}
But indeed agreein with ArkM what is n?
Chris
You should check how to use If & Else stantements, you have
if(standarddeviation>0){
cout<<"standardeviation: "<<standarddeviation<<endl;
else
cout<<"standarddeveiation not valid.";
}
This is wrong due to bracket positioning it should be
if(standarddeviation>0){
cout<<"standardeviation: "<<standarddeviation<<endl;
}
else{
cout<<"standarddeveiation not valid.";
}
Im guessing you mean in relation to realy time, you may want to use CLOCKS_PER_SEC to get things in terms of time and in terms of time to clocks for example divide clock()/CLOCKS_PER_SEC withh give you how many seconds, etc and if you want to wait for x seconds do seconds*CLOCKS_PER_SEC
Chris
Good sorry i should of paid attention to the fact you were using floats, i would then of suggested 9.0f/5.0f :P
Glad its sorts, if there are no more problems then mark thread as solved
Chris
Trying doing 9.0/5.0 rather than just 9/5
Chris
usethe string header so you can get the path from the user then pass it to chdir like this
chdir(path.c_str());
Chris