|
your code is almost correct but in pound there is a no 100 to 300, how can I put it in my code, but thanks a lot
|
|
|
|
|
Well it is, kindof. The format specfier to printf is wrong.
Try this
#include <stdio.h>
#define POUNDTOKG 0.453592
int main() {
printf("Pound --------- Kilos\n\n");
for (int pound = 100; pound <= 300; pound++) {
printf("%d pound = %.2f Kilogram\n", pound, pound * POUNDTOKG);
}
return 0;
}
Pound --------- Kilos
100 pound = 45.36 Kilogram
101 pound = 45.81 Kilogram
102 pound = 46.27 Kilogram
103 pound = 46.72 Kilogram
...
298 pound = 135.17 Kilogram
299 pound = 135.62 Kilogram
300 pound = 136.08 Kilogram
...Program finished with exit code 0
Press ENTER to exit console.
|
|
|
|
|
That's great, thanks a lot for your help and finally I will pass my pre-final exam in c programming, thank you
|
|
|
|
|
it doesn't work setwindowsHookEx(), Getkeystate() and GetCursorPos().
please help me.
modified 12-May-22 0:51am.
|
|
|
|
|
Windows service applications do not have consoles so have no access to input or output devices.
|
|
|
|
|
Windows services don't run in the context of a user's desktop. At any point whilst the service is running, there could be zero, one, or many users logged in to the computer, each with their own desktop.
You need to use a different solution. For example, you can use the Windows Task Scheduler to start an application when any user logs in. That application will have access to the user's desktop.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I got the conflicting types error when I built the code, while, i searched the workspace, i only found one tyepdef,
Shrink ▲ Copy Code
typedef unsigned int uint32_t;
in Eclipse, search:typedef*uint32_t
i can't find where there is another typedef * uint32_t.
Please help to give some ideas.
|
|
|
|
|
focusdoit wrote: Please help to give some ideas. Show the code that has the problem, and the exact error message(s).
|
|
|
|
|
focusdoit wrote: Please help to give some ideas. The error message implies that you are calling a function that expected a uint32_t so check the function signature of every function you are calling.
I don't understand why nearly everyone that posts a question omits pertinent information. It would really help if you posted relevant code and error messages.
|
|
|
|
|
Thanks, it's a big project,
i found the issue,
new 1 (33 hits)
XXX_Global.h: error: conflicting types for 'uint32_t'
Line 17: typedef unsigned int uint32_t;
gcc-6.3-arm32-eabi\arm-none-eabi\include\sys\_stdint.h:48:20: note: previous declaration of 'uint32_t' was here
Line 24: typedef __uint32_t uint32_t ;
there are 2 tyepdef uint32_t
|
|
|
|
|
focusdoit wrote: i found the issue I'm happy to see you made progress. It's unusual to ask this type of basic question, you should change the variable type on those function calls to uint32_t and recompile.
It would be great if you revealed the source code. You are forcing anyone that assists you to speculate.
|
|
|
|
|
Then remove the one from XXX_Global.h.
|
|
|
|
|
Hi
I have the following collection class (referencing a struct) which is causing the complier error listed below
I ended writing my own link list becuase I couldnt resolve the issue however I am hoping that by posting this someone can maybe explain it to me
so here is the code
listed below is the complier error for some reason the complier doesnt like a Clist template in a struct
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\atlmfc\include\afxtempl.h(954,17): error C2280: 'CStorge::buildcombo::tcbholder &CStorge::buildcombo::tcbholder::operator =(const CStorge::buildcombo::tcbholder &)': attempting to reference a deleted function
struct stdecs
{
struct vsmdesc stordesc;
char* tcb;
struct blkdesc *ablkdescx;
struct blkdesc *fblkdescx;
struct stdecs* nextdecs;
};
struct tcbholder
{
char* tcb;
char programname[8];
struct stdecs *storageptr;
CList<stdecs, stdecs> stptr;
};
|
|
|
|
|
CList features a deleted copy contructor.
Microsoft folks think it is not useful to pass collections by value.
You could use std::list instead (I believe Microsoft folks themselves recommend std::list over CList ).
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
|
You are welcome.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Still get error with list me thinks it has to do that I declared stdecs just as a type without actually allocating storage i.e struct stdecs storagediscriptor; when I have the template outside of a struct it compiles thanks
|
|
|
|
|
This works for me:
#include <iostream>
#include <list>
using namespace std;
struct Foo
{
list <int> foolist;
};
int main()
{
Foo f1;
f1.foolist.push_back(5);
f1.foolist.push_back(7);
Foo f2 = f1;
for (auto i: f2.foolist)
cout << i << " ";
cout << "\n";
}
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Get clean build seems to do more than clist thanks
|
|
|
|
|
I cannot create MyListBox derived from CFormView. The docs say I can put the Create call in the MyListBox ctor.
I get these errors:
// dialog template must exist and be invisible with WS_CHILD set
// invalid dialog template name
I don't want to create a resource dialog template, however, like an IDD_... because my listbox is just a PLACE_HOLDER control in a resource control.
How do I get the object created without a dialog resource IDD?
|
|
|
|
|
What does the relevant code look like?
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hi,
I am following an example from a book, and I have an WaitForSingleObject that works just first time and I don't know
how to resolve that.
The main things are happening in the ChildThreadProc. At the first execution of the ChildThreadProc the procedure steps through all lines of code, but when is launched again, the execution stops at WaitForSingleObject, as if hAutoEvent isn't signaled or I don't know what is happening, and please help me to figure this out.
So,
In the WindProc main procedure when the window is created, is created the Event also:
case WM_CREATE: hAutoEvent = CreateEvent ( NULL, FALSE, TRUE, "EXAMPLE-AUTOEVENT" );
return DefWindowProc(hWnd, message, wParam, lParam);
The example of WaitForSingleObject is presented in the following procedure:
DWORD WINAPI ChildThreadProc ( HWND hWnd )
{
char szBuffer[256]; HANDLE hAutoEvent = OpenEvent( SYNCHRONIZE, FALSE, "EXAMPLE-AUTOEVENT");
wsprintf(szBuffer, "Thread %x waiting for Event %x", GetCurrentThreadId(), hAutoEvent );
SendMessage(hWnd, WM_USER, 0, (LPARAM)szBuffer);
WaitForSingleObject(hAutoEvent, INFINITE );
wsprintf(szBuffer, " Thread %x got event", GetCurrentThreadId() );
SendMessage(hWnd, WM_USER, 0, (LPARAM)szBuffer );
Sleep(2000);
wsprintf(szBuffer, "Thread %x is dome with event", GetCurrentThreadId() );
SendMessage(hWnd, WM_USER, 0, (LPARAM)szBuffer);
SetEvent(hAutoEvent);
CloseHandle( hAutoEvent);
ExitThread( TRUE );
The ChildThreadProc is started here:
case IDM_TEST:
{
DWORD id=0;
CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)ChildThreadProc, hWnd, 0, &id );
}
break;
and here is where text out is handled:
case WM_USER:
{
TCHAR szBuffer[101];
static int row = 0;
static int msg_num = 1;
HDC hDC = GetDC(hWnd);
FillMemory(szBuffer, 100, 32 );
TextOut( hDC, 0, row, szBuffer, 100 );
wsprintf(szBuffer, "%3d: %s", msg_num++, (LPSTR)lParam );
TextOut(hDC, 0, row, szBuffer, lstrlen(szBuffer) );
row = (row > 200 ) ? 0 : row += 20;
ReleaseDC(hWnd,hDC);
}
break;
Please help me to find what I am not doing right.
Thank you,
|
|
|
|
|
coco243 wrote: execution stops at WaitForSingleObject, as if hAutoEvent isn't signaled or I don't know what is happening
coco243 wrote: Please help me to find what I am not doing right. It's not signaled on the second pass. You are using an Auto-Reset event object. So when your ChildThreadProc thread exits the event goes back into a nonsignaled state. The operating system is managing this for you.
Event Objects (Synchronization) - Win32 apps | Microsoft Docs[^]
You could change to a manual signal and set/reset it yourself.
Best Wishes,
-David Delaune
|
|
|
|
|
Thank you, I had made the event with manual reset and I had understood what it was to be understanded.
In additon, the main significant thing that I had catched it, it was that when the thread was exiting, even if I was signaled the event before exiting from thread:
SetEvent(hAutoEvent);
, the system automaticaly was unsigning the event.
Very tricky for me, I woldn't figured out by myself neither in 100 year, so,
Thank you very much,
|
|
|
|
|
coco243 wrote: I woldn't figured out by myself neither in 100 year You are doing an amazing job. I would be completely lost if I were forced to read Romanian documentation. I checked and unfortunately the MSDN isn't available in your native tongue. Event Objects (Romanian)[^]
|
|
|
|
|