|
What you are describing sounds like the device and application would have to access the same memory. I am not sure that makes any sense if you are using a serial port for communications. Did I miss something?
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
I want to give password protection to one of my screens. I am calling this do while loop in the initinstance of that screen the problem is now if i press cancel button then the password dialog box should go but its not going and if its going then it opens my screen.
do
{
if(password.DoModal()==IDOK)
{
if(password.m_strPassword !=File.getKeyValue("PASSWORD","password"))
AfxMessageBox("Invalid Password ");
}
}while(password.m_strPassword !=File.getKeyValue("PASSWORD","password"));
Please Help me out
|
|
|
|
|
Try this
while(1)<br />
{<br />
if(password.DoModal()==IDOK)<br />
{<br />
if(password.m_strPassword !=File.getKeyValue("PASSWORD","password"))<br />
{<br />
AfxMessageBox("Invalid Password ");<br />
}<br />
else<br />
{<br />
break;<br />
}<br />
}<br />
else<br />
{<br />
return FALSE;<br />
}<br />
}
|
|
|
|
|
Even this is not working On preesing the cancel the screen is displayed
|
|
|
|
|
this progream must show me all the possible shuffled randomisation....but it only displays one result...i tried many ways but still doest work..isit anything with my code...check for me...plz let me know if there is any solution for this as soon as possible..thank u..
<code>#include <ctime>
#include <iostream>
#include <string>
#include <algorithm>
#include <fstream>
using namespace std;
time_t tmStart, tmEnd;
void DoStuff()
{
tmStart = time(0);
ifstream fin("data.txt",ios::in);
ofstream File("MyFile.txt",ios::out);
char str[14];
// fin.getline(str,sizeof(str),'\n');
// string line(str);
//cout << str<<endl;
int i=0;
// while(fin.eof() == NULL )
while(true)
{
if(fin.getline(str,sizeof(str),'\n'))
{
string line(str);
random_shuffle(line.begin(), line.end());
File << "Randomised: " << line << endl;
File << " : " << line << endl;
File << " : " << line << endl;
File << " : " << line << endl;
File << " "<< endl;
// File << "Single Row: " << s << " " << s << " " << s <<" " << s << endl;
File << " "<< endl;
++i;
tmEnd = time(0);
cout << tmEnd-tmStart << " seconds " << endl;
}else break;
}
File.close ();
fin.close ();
}
int main(int argc, char* argv[])
{
DoStuff();
return 0;
}
</code>
|
|
|
|
|
There is nothing random about getting all the possible permutations of a sequence: it's a systematic process.
Steve
|
|
|
|
|
i cant get it...explain more detail pls..
|
|
|
|
|
Imaging you have a dice with 100 sides each labeled with a number. If you want to make a list of all the numbers how do you proceed? One way would be keep rolling the dice and if the number you roll is not on your list you add it. This is very inefficient and non-deterministic however. A simper way would be just to inspect every side. This is similar to the problem you’re having. Using a random shuffle in a loop is not a good way to get every permutation of a sequence: although eventually it will product every combination.
Steve
|
|
|
|
|
is there any othe methods to solve the problem...if i cannot use random shuffle what i must use..
|
|
|
|
|
Maxwell is correct, use next_permutation . The first permutation is the sorted one so you should do this first: sort(s.begin(), e.end());
Steve
Steve
|
|
|
|
|
Hi Steve,
Should we provide a working sample code for THIS[^]?
Maxwell Chen
|
|
|
|
|
I just did - I want this thread to end.
Steve
|
|
|
|
|
std::next_permutation(it.begin(), it.end());
Maxwell Chen
|
|
|
|
|
i tried dis b4...but still the same result...i want all the possible integer randomisation..
for example...
my input file contents... 1234
my output must give the result as
4321
2341
2314
4213
1243
..
..
..
and so on...
all the possible randomised shuffling...
icant get it....is there any possible way..
|
|
|
|
|
If you had of tried it it would have worked. Here's a program which demonstrates this technique:
------------
// Console.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc, char* argv[])
{
string s("1234");
sort(s.begin(), s.end());
do
{
cout << s << endl;
}
while ( next_permutation(s.begin(), s.end()) );
return 0;
}
Steve
|
|
|
|
|
Hey all im making a game for school on MFC and im having trouble making it so when I press W,A,S, or D it will move my character... I know how to make him move if I press the arrow keys (previous game):
case VK_DOWN: //IF DOWN BUTTON IS PUSHED
{
}
I have already tried VK_A, any help would be appreciated!
Thanks
|
|
|
|
|
|
I think you need this
case VK_DOWN:
case 'S':;)<br />
{<br />
...<br />
break;<br />
}<br />
<br />
case VK_UP:
case 'W':;)<br />
{<br />
...<br />
break;<br />
}<br />
<br />
...
|
|
|
|
|
why small ball jump, background bmp jump too?
I write the code.
I want to ball jump, backgroud bmp do not jump?
Has the solution?
thanks.
source code:
http://ComAndATL.googlepages.com/Game.part1.rar
http://ComAndATL.googlepages.com/Game.part2.rar
If you solution, may the code which solution send my email zhmster@gmail.com.
very very thanks you !
alantop
-- modified at 15:34 Sunday 7th May, 2006
|
|
|
|
|
update!
alantop
-- modified at 4:58 Monday 8th May, 2006
|
|
|
|
|
I need to convert an unsigned int to a char*.How can I do it??
Thanks in advance!!
|
|
|
|
|
#include <stdlib.h>
#include <stdio.h>
void main()
{
unsigned int i = 123;
char p[100];
itoa(i, p, 10);
printf("%s\n", p);
}
alantop
|
|
|
|
|
alan top :
<br />
void main()<br />
{<br />
unsigned int i = 123;<br />
char p[100];<br />
<br />
itoa(i, p, 10);<br />
printf("%s\n", p);<br />
}<br />
-----------and-----------------
unsigned int a=100;
char *buffer;
buffer=(char*)LocalAlloc(LPTR,20);
itoa(a,buffer,10);
unsigned int c;
c=atoi(buffer);
LocalFree(buffer);
|
|
|
|
|
Here is another way to do this
unsigned int i=100;
char p[10];
sprintf(p,"%u",i);
cout<<p;
Knock out 'T' from CAN'T ,
You 'CAN' if you think you 'CAN'
|
|
|
|
|
You can Also use Reinterpret_cast
Thanks & Regards
Banks
|
|
|
|