|
Thx. But when i compile it i get the following error :
'%': Illegal, left operand has type 'double'
Unix and C are the ultimate computer viruses.
Visit me: www.programming.info.ms
|
|
|
|
|
MSDN says: The modulus operator (%) has a stricter requirement in that its operands must be of integral type.
just cast the pow() function to a (long)
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Try this...
long value = ((long)pow(long1, long2)) % long3;
Jeremy Falcon
|
|
|
|
|
I suggest you do it manually with repeated multiplings and the apply the modulus
gabby
|
|
|
|
|
I am creating a small application that is going to run on a network. I need to know the number of people that are running the application on the network. I had tried looking for an example on how to this but I can’t find any. Any help!!!
|
|
|
|
|
When the application is started, you could simply write a "counter" number to some file. There are obviously lots of implications in doing this, but it is simple.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
HMODULE hm = LoadLibrary("http://some.server.net/downloads/a.dll");
Of course I know that the above does not work. Implementing the HTTP part is no problem, but how do I simulate LoadLibrary without an actual file?
(storing the downloaded DLL in a temporary file is not an option, I want real "zero footprint")
|
|
|
|
|
when i need cast cstring into float , i always use sscanf(mystr,"%f",ftype)//float ftype
fype=atof(mystr)
but which is better ,what is the difference between them?
|
|
|
|
|
atof() will be faster because it does not have to parse a format string like sscanf() does.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
atof is faster and smaller since it does not have the overhead of a format string scanner - I would think that sscanf calls atof when it finds the %f in a format string. FYI, you are not doing a cast, you are doing a conversion.
Steve
|
|
|
|
|
hi:i create a dialog such as CMyDlg, i define a variable :CBrush m_brush,
then i in onInitDialog :m_brush.CreateSolidBrush(RGB(255,255,0))
then HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (pWnd->GetDlgCtrlID() == IDC_STATIC)
{// Set the text color to red
pDC->SetTextColor(RGB(255, 0, 0));
// Set the background mode for text to transparent
pDC->SetBkMode(TRANSPARENT);
// Return handle to our CBrush object
hbr = m_brush;
}
return hbr;
}
but the text color is not i expected,and at the back of the text ,always exist white ?how to modify?but if i do these work in main dialog ,all is ok.
|
|
|
|
|
Seems brushing is ok, so it should work. Though I want to point out two things;
1) Do not use pWnd->GetDlgCtrlID() == IDC_STATIC condition unless you assign a unique id to a static control (e.g. IDC_MYSTATIC). Instead, if you want to consider all the static controls, test against nCtlColor == CTLCOLOR_STATIC.
2) Why not to set the text color;
pDC->SetTextColor( some rgb );
--
=====
Arman
|
|
|
|
|
|
Hi
modified 12-Sep-18 21:01pm.
|
|
|
|
|
how to cast cstring into long,double?
|
|
|
|
|
_atol() , _atof()
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
Hello,
I am very new to VC++6 and have a problem that is driving me crazy.
I have class defined as so:
#define True 1
#define False 0
#ifndef CLASSIFER_H_INCLUDED__
#define CLASSIFER_H_INCLUDED__
class CClassifier
{
public:
//--------------------------------------------------------------------------
// constructor
//--------------------------------------------------------------------------
CClassifier
(
LPCTSTR szCommand,
CEdit *pEdit,
LPCTSTR szCurrentDirectory = NULL
);
//--------------------------------------------------------------------------
// destructor
//--------------------------------------------------------------------------
virtual ~CClassifier();
//--------------------------------------------------------------------------
// public member functions
//--------------------------------------------------------------------------
// virtual void Run();
virtual void Run(CString& cfn);
virtual void Stop();
...
I do some processing in the Run function, and eventually have a CString variable called 'classification' that gets assigned to 'cfn' before I return.
Now, the problem is in WinXP, when I try to use an AfxMessageBox to have a debug look at the value of 'classification' inside CClassifier.Run, i.e.,
text.Format(_T("Inside Classifier.Run\nclassification = %s"),classification);
AfxMessageBox(text);
the message box fires, but 'text' has no value. Under Win2k, it works fine, just not undet WinXP.
I call the Run function like so:
m_pClassify = new CClassifier((LPTSTR)(LPCTSTR)FileBuf, &m_EditOutput);
m_pClassify->Run(classified);
where FileBuf is a CString.
The return value 'classified' does not get a value under WinXP, but it does under Win2K.
This is driving me crazy and holding up progress on my project, so I really would appreciate some help with this.
Thanks,
Murrah Boswell
|
|
|
|
|
Your problem is likely a bug in your code. You don't really give enough information to try and debug it.
XP has new memory allocator that exposes bugs in your code that previously worked. Typically, these are uninitialized pointers, re-use of deleted pointers, use of stack variables that have already been "popped", etc..
You're also using some weird casting there. Why are you casting a constant to a non-const in the constructor? Over-casting is usually a sign of error as well.
--
Where are we going? And why am I in this handbasket?
|
|
|
|
|
Hello,
Thanks for the reply!
How much code do you need/want to look at? In the Run function, I am using CreateProcess to open up read/write pipes to dos batch files. I use the batch files to run a .exe file with various switches. Hence the separate batch files. The .exe file reads in files stored on disk.
Then I capture the output from the batch files (actually the .exe file) and parse it for certain key words and based on occurances of the key words, I classify the files read from disk into categories.
I will send this code if you want.
As far as the casting in the constructor, I assume you are talking about
LPCTSTR szCurrentDirectory = NULL
This is how Microsoft describes how to use the szCurrentDirectory variable in CreateProcess:
LPCTSTR lpCurrentDirectory
[in] Pointer to a null-terminated string that specifies the full path to the current directory for the process. The string can also specify a UNC path.
If this parameter is NULL, the new process will have the same current drive and directory as the calling process.
(This feature is provided primarily for shells that need to start an application and specify its initial drive and working directory.)
I really do need some help on the original problem of why WinXP returns zilch, so if you want to look at some of the code, I would appreciate it.
Thanks again,
Murrah Boswell
|
|
|
|
|
Actually, no. The casting I was referring to was this:
CClassifier((LPTSTR)(LPCTSTR)FileBuf, &m_EditOutput);
You're casting FileBuf to an LPCTSTR, and then to an LPTSTR, which then get's cast back to an LPCTSTR implicitly by the constructor.
Anyways, sure. I can take a look at your code. If you can make it available on an FTP or web server, that would be preferrable.
--
Where are we going? And why am I in this handbasket?
|
|
|
|
|
hi,
i got a class myView derived from CFormView.
in my mainmenu i call openMyView() -
what need i to do to display myView??
i tryed :
myView *m = new myView;
but i get an error message about protected constructor...
help anyone?
Avi.
|
|
|
|
|
what is the relationship between the execute file one disk and loading in the memory?
|
|
|
|
|
What do you mean by "relationship?" Beginning with 32-bit Windows, when an EXE is loaded from disk into memory, very little, if any, is required of the Windows loader to create a process. It uses the memory-mapped file mechanism to map the appropriate pieces of the file into the virtual address space. The memory used by the module for code, data, resources, import tables, export tables, and other required data structures is in one contiguous block of memory. Unlike the 16-bit files where portions of the file were read in and completely different data structures were created to represent the module in memory. When the code or data segment needed to be loaded, the loader had to allocate a new segment from the global heap, find where the raw data is stored in the executable file, seek to that location, read in the raw data, and apply any applicable fixups.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thank you very much.
I use the Memory-mapped file mechanism load the program file from disk (using the CreateFileMapping(),MapViewOfFile()), and I can analyizing the PE header, Option header, section tables and the section raw data. verything is ok.
so I run this program, and use Tool Help functions (CreateToolhelp32Snapshot(),Process32First(),Module32First() etc..) to obtain the process ID, then use the Toolhelp32ReadProcessMemory() function copy the process memory into a buffer. the useing the PE specific to analyze the buffer data. I can get the correct PE DOS-Header, the Option header, and the section table, but I can not get the correctly Section data like use the Memory-mapped file mechanism.
So I think the Memory-mapped file mechanism and the Windows Kernel load the file into memory and create the process are different. so I need know what is the different.
In the PE option header, there are the BaseOfCode and BaseOfData fields, and in the section header, there are the same section. so I read this section rawdata, and want to search these data in the process memory. but I can not find. then I use the same mechanism like Memory-mapped file to dump all of the process memory. I find that the PE header are same, but the section rawdata is differnt. so I don't know what's the different.
thank you very much.
|
|
|
|
|