|
what is this supposed to do ?
what is the input and what is the output ? (what are the test cases ? )
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
You know, you cannot get an empty string using cin (see, for instance, Get empty input - C++ Forum[^]).
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Maybe its a contest. Guess the point and win the prize.
I do note that there are two possible inputs. So if '1' was put in for the first one, then I expect it works.
If put in for the second then I suspect '2', ..., '9' would also fail.
|
|
|
|
|
Se desea realizar una aplicación para llevar el control de las producciones que tiene una brigada de estudiantes en una empresa de cultivos varios en el mes de noviembre, la tarea es la recogida de tomates.
Es de interés para la empresa conocer.
a-Cuantas cajas de tomates se recogieron al analizar el mes.
b-En cuantos días la brigada cumplió la norma de producción. Tener en cuenta que la norma de producción es de 100 cajas.
c-La cantidad máxima de cajas recogidas.
d-La cantidad mínima de cajas recogidas.
e-El promedio de cajas recogidas en el mes.
f-Saber en cuantos días supero el promedio de cajas recogidas.
Haga uso del subprograma
PromedioCajas(), del inciso e.
Recuerde desarrollar un programa principal en el que se controle las llamadas a diferentes subprogramas que den solución a las necesidades existentes. Defina un menú, para que el usuario seleccione la opción que desee.
Translation:
We want to make an application to keep track of the productions of a brigade of students in a company of various crops in the month of November, the task is the collection of tomatoes.
It is in the company's interest to know.
a-How many boxes of tomatoes were collected when analyzing the month.
b-In how many days did the brigade comply with the production standard? Please note that the production standard is 100 boxes.
c-The maximum number of boxes collected.
d-The minimum number of boxes collected.
e-The average number of boxes collected in the month.
f-Know how many days I exceed the average number of boxes collected.
Make use of the applet
AverageBoxes(), of subsection e.
Remember to develop a main program in which you control the calls to different subprograms that provide solutions to existing needs. Define a menu, so that the user selects the option they want.
|
|
|
|
|
Do your own schoolwork.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
In C++ you have ints, variables for floating point numbers, bools. Does Assembly have the same variable differentiation? Can you move any type of variable into a register?
|
|
|
|
|
yes and no.
There's no types in assembly.
You just move data to a register; the data can be anything (int, float, address to a string, ...)
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
Not entirely true: floating point registers are still separate AFAIK. The rest are all the same.
Mircea
|
|
|
|
|
What about db, dw, dd, dq ... ?
|
|
|
|
|
Assembler does have (sort of) data types, in the way that you declare variables. But at the instruction level it is up to the programmer to ensure that the items are handled correctly. Take a look at NASM - The Netwide Assembler[^] for specific details.
|
|
|
|
|
Richard MacCutchan wrote: it is up to the programmer to ensure that the items are handled correctly Truth!
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Richard thanks for your reference.
|
|
|
|
|
You are welcome. And NASM is a good introduction to Assembler, and machine code.
|
|
|
|
|
Thanks for your feedback guys
|
|
|
|
|
Hi,
as learning process, i need some code (or simple sample project) that shows how to post?send message from a library (dll) to application (dialog or console). If a thread in dll sends message to app, how is the best to approach that?. Using GetMessage?.
|
|
|
|
|
Keep in mind of course that a library doesn't do anything. Applications do stuff and use libraries.
So you want two applications.
You can start with researching (google) examples of Rest (http.)
|
|
|
|
|
Yes.
I am trying to experiment another feature that may become handy.
|
|
|
|
|
|
same message id is created in dll and in application?.
in application there is a routine that polls the messages. correct?.
|
|
|
|
|
Yes, you can create a message inside a DLL and send it to an application. But that still needs a controlling application to drive the DLL; so why would you do it that way? .A Windows (as opposed to a Console) application, must contain a message pump which pulls messages from its queue and processes them.
|
|
|
|
|
in case DLL need to inform application of something changed.
callback is better for this case?.
|
|
|
|
|
An unequivocal YES! Sending window messages is about the least flexible thing you can use because it's limited to being used only with Windows applications that have a message pump. That keeps you from using it in Console apps, Service apps, and all web applications.
|
|
|
|
|
wizQ wrote: in case DLL need to inform application of something changed. I think you misunderstand the role of a support library. A library (whether .lib or .dll) is a set of passive functions that are only activated when called from an application (Console or Windows). So it is unlikely that they would be able to "know" when anything happened that needed to be communicated to other applications.
|
|
|
|
|
//TestDll2.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl NS::A::A(int (__cdecl*)(class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >))" (__imp_??0A@NS@@QEAA@P6AHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z@Z) referenced in function main
=====file TestDll2.cpp=====
#include <iostream>
#include "..\\MyDll\\MyDll.h"
using namespace std;
using namespace NS;
int Print(string str);
int main()
{
NS::A* a = new NS::A(Print);
NS::printDlgt("Hello World!");
}
int Print(string str)
{
cout << str << endl;
return 0;
} MyDll project files
=====MyDll.cpp=====
#include "pch.h"
#include "MyDll.h"
namespace NS
{
PrintDelegate printDlgt;
A::A(PrintDelegate print_Dlgt)
{
NS::printDlgt = print_Dlgt;
}
}
=====MyDll.h=====
#include <iostream>
#ifndef MYDLL_H
#define MYDLL_H
#ifdef MYDLL_EXPORTS
#define MYDLL_API __declspec(dllexport)
#else
#define MYDLL_API __declspec(dllimport)
#endif
using namespace std;
typedef int (*PrintDelegate)(string str);
namespace NS
{
extern PrintDelegate printDlgt;
class MYDLL_API A
{
public:
A(PrintDelegate print_Dlgt);
};
}
#endif
|
|
|
|
|
Oscar K. wrote: //MYDLL_EXPORTS is set in C++\Preprocessor
What do you mean by that? MYDLL_EXPORTS should only be defined in MyDll.cpp, just before the #include "MyDll.h" . You also need to ensure that you add MyDll.lib to the linker options in your build.
[edit]
On reflection I think maybe the definition of extern PrintDelegate printDlgt; is not correct. I think it should also by declared with MYDLL_API .
I will try and test this later today.
[/edit]
modified 17-Mar-24 5:19am.
|
|
|
|