|
I find the best way to handle this is to create all of the controls you'll need and then just enable/disable them at runtime.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks again for the information.
A C++ programming language novice, but striving to learn
|
|
|
|
|
how can I use the code of c++ in a function (like checksum) as a string in the same project ?
in another way :
I want to apply a function on the cpp file as a text one to calculate its text value
|
|
|
|
|
your question is not clear.
I'm not even certain _you_ understand what you wan to achieve ?
- you want to copy/paste the code from one function to another one ?
- you want to have a textual representation of a function and call it ? (ie. a bit like an interpreter does ?)
- apply what ? to what ?
- you want to have a text representation of the output of a function like "checksum"? (ie. print the result?)
- ...
This signature was proudly tested on animals.
|
|
|
|
|
when I try to "restart system" or "turn off system" , I get error message "Socket Notification Sink" Dialog box.
And it didn't work reboot or turn off..
How can I avoid "Socket Notification Sink" error?
My main brief code as followings.
<br />
<br />
<br />
UINT _ThreadDoSomethingInfinite(LPVOID pParam)<br />
{<br />
<br />
char buf[100];<br />
CSocket h_sock;<br />
CMyDlg *p=(CMyDlg*)pParam;<br />
h_sock.Create( nPort , SOCK_DGRAM);<br />
while(1)<br />
{<br />
<br />
Sleep(5000); <br />
. <br />
.<br />
stcpy(buf, "some data..buffering..");<br />
<br />
h_sock.SendTo( buf , 1234 , "127.0.0.1" ); <br />
}<br />
<br />
h_sock.ShutDown(2);<br />
h_sock.Close();<br />
}<br />
<br />
<br />
CWinThread g_updsock;<br />
BOOL CMyDlg::OnInitDialog()<br />
<br />
g_updsock=AfxBeginThread(_ThreadSendAgentStatus,this,THREAD_PRIORITY_NORMAL);<br />
if(g_updsock==NULL) return;<br />
<br />
}<br />
<br />
|
|
|
|
|
Hi, I suggest to exit the endless loop when the application is signaled to terminate or an error occured. Add basic error handling to the socket methods, e.g. Create and SendTo return a status. Alternatively use a different socket class than MFC's CSocket or use plain sockets (Winsock).
/M
|
|
|
|
|
Can anyone help me how to convert a DAT file to a BMP file?I have created a DAT file.Now while converting it to a BMP file, how can i insert the bmp header?
|
|
|
|
|
What is in that DAT file? I presume it is an image, do you know the width, height and color depth?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Yes.There is an image.
Actually i have converted a bmp image to a dat file(i have taken a 2D matrix,represented the foreground pixels with "1" and the background pixels with "0") for various operations like thinning,segmentation etc.Now i want to convert my modified dat file to bmp file.i know the width and height of 2d matrix.
how can i insert the bmp header at the beginning of the dat file?
|
|
|
|
|
Well, i guess if you know the BMP format[^], all you have to do is fill out a BITMAPFILEHEADER[^] structure, then fill out a BITMAPINFO[^] and then write them to a file in the following order: BITMAPFILEHEADER, BITMAPINFOHEADER, DAT(a). Does this help?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
hi,
i got a hash value which i wanna convert to 8 digit numbers.
for e.g hash values:
string hash = "df310c24eb35eee2af4f83bed8bee284";
i wanna convert this hash value into 8 digit numbers. how can i do so??
tks in adv
|
|
|
|
|
This string contains 32 hexadecimal digits. So may represent 16 bytes, as well 8 shorts, as well 4 int.
If you need to convert it into an array of bytes (unsigned char) try something similar to:
#include <stdio.h>
void main()
{
char hash[] = "df310c24eb35eee2af4f83bed8bee284";
char * p = hash;
const unsigned int SIZE = (sizeof(hash)-1)/2;
unsigned char arr[SIZE];
unsigned int count=0;
while (count < SIZE)
{
if (sscanf(p, "%2x", &arr[count]) != 1)
{
}
count++;
p+=2;
}
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
hi everyone who reads this,
i am in a digital electronics class and i decided to write a program that converts decimals to binary, i thought this was going to be simple and it was till i realized my my loop cout'ed the binary in reverse order. 731 in dec = 1011011011 and my program did it in reverse 1101101101 i used int's with modulus and division operators:
while (num)
{
rem=num%2;
num = num/2;
cout << rem;
}
so i was wondering is there a simple way to reverse the output or could the division be done in reverse so the last output is first and the first last in my program? please note i am a beginner at c++ so i don't know how to do arrays as of yet and i am sure the output could be loaded into an array and printed in reverse order.
thank you in advanced for any help.
|
|
|
|
|
You should go in the opposite way, using multiplication (or bit shif, that is faster):
#include <iostream>
using namespace std;
void main()
{
unsigned int k = 731;
unsigned int b;
const int SIZE = sizeof(k) << 3;
const unsigned int MSB = 1 << (SIZE-1);
for (b=0; b<SIZE; b++)
{
cout << (( MSB & k) ? 1 : 0);
k <<= 1;
}
cout << endl;
}
Or
#include <iostream>
using namespace std;
void main()
{
unsigned int k = 731;
unsigned int b;
const int SIZE = sizeof(k) << 3;
const unsigned int MSB = 1 << (SIZE-1);
bool isLeadZero= true;
for (b=0; b<SIZE; b++)
{
if ( MSB & k)
{
isLeadZero = false;
cout << 1;
}
else
{
if ( ! isLeadZero) cout << 0;
}
k <<= 1;
}
cout << endl;
}
If you need to remove heading zeroes.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
i just tried your code and it works very well, there is one thing, i just cant seem to understand how it works line by line, since i want to learn c++ i think it wise to at least understand how it works, could you explain how your code outputs so many leading zero's, i find that very interesting.
|
|
|
|
|
In order to obtain the correct result (i.e. reversed bits) using your method, you need to multiply instead of dividing. At every iteration you have to:
- Test the most significative bit of the number.
- miltiply the number by two, so that the most significative bit is replaced by its adjacent one (the next you'll test).
In my code I replaced multiplication by 2 with left shift that is faster.
Dealing with MSB (most significative bit) is a little trcky since its position depends on the data type, i.e. it is bit 7 for unsigned char s, bit 15 for 2 -byte data types (like short on my machine) and bit 31 for 4 -byte data types (like unsigned int on my PC) hence the 'messy' lines in my routine, for instance:
const int SIZE = sizeof(k) << 3; Here SIZE is set to the length, expressed in bits, of k (sizeof operator returns bytes, I multiply by 8 using, again, left shift operator).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
thank you very much, i will play with this code and see what i can do with this new information.
you said you multiplied by 8, but i see only 3 could you explain this, if it was a typo then never mind
|
|
|
|
|
You are welcome.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
i figured out what you meant by multiply by 8, it would be 2^3 which is 8 and what i seen in your code was 3. it seems this is a cool way to multiply and divide
i hope this thread helps someone else learn something new as i did, thanks
|
|
|
|
|
There are many ways to do this. To use what you already have, add:
char s[128] = { '\0' };
int x = 0;
while (num)
{
s[x] = (num & 1) ? '1' : '0';
num = num / 2;
x++;
}
cout << strrev(s) << endl;
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
its funny i was reading about arrays today and ways to reverse the output, had nothing yet, but i did learn how to make an array. what header files did you use? when i compile your modification to my code i get an unrecognizable output.
thank you.
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
char s[128];
int x = 0;
int num =53
while (num)
{
s[x] = (num & 1) ? '1' : '0';
num = num / 2;
}
cout << strrev(s) << endl;
system("pause");
return 0;
}
|
|
|
|
|
Have you used the debugger to step through the code watching s and num ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
i haven't looked at the debugger messages, maybe i should, but as a beginner i may not even know what i am seeing so i will look into this. thanks
|
|
|
|
|
HI
Would U plz help me with this Code
I cant find the Error !!
here's the Question:-http://uva.onlinejudge.org/external/1/136.html[^]
here's the code .. "that shows a wrong output"
#include<iostream>
#include<list>
using namespace std;
int main ()
{
int uglylist[1500];
uglylist[0]=1;
int maximum;
int max2=0;
int max3=0;
int max5=0;
for(int i = 1; i<1500; i++)
{
maximum =uglylist[i-1];
for(int j=0;j<=i;j++)
{
if (uglylist[i]>max2)
{
max2=uglylist[j]*2;
break ;
}
if (uglylist[i]>max3)
{
max3=uglylist[j]*3;
break ;
}
if (uglylist[i]>max5)
{
max5=uglylist[j]*5;
break ;
}
uglylist[i]=min(max2,min(max3,max5));
}
}
cout<<uglylist[1500-1]<<endl;
}
So Would U plz help ?
|
|
|
|
|
Would U plz do your own homework?
|
|
|
|