|
Stephanie Foley wrote: I need help with this Exactly what help do you need?
|
|
|
|
|
I need to use an input file to find that course average. The course average is a mathematical expression involved in quiz average, midterm grade, and final grade. I am trying to get the program to read what is in the file. There is the first name, last name, and 7 numbers. I need to use these values in the program to get an average for the class.
-- modified 6-Jun-22 16:22pm.
|
|
|
|
|
Well you stated that in your original question. But you have still not explained what your problem is.
|
|
|
|
|
How are your results different from what is expected? Also, showing the files exact contents would be helpful.
"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
|
|
|
|
|
I found, a statement,
int &a = 1;
the statement can be built in QT Creator, mingw_64.
while on Programiz: Learn to Code for Free[^]
Got,
gcc /tmp/BlXEG8NqhU.c -lm
/tmp/BlXEG8NqhU.c: In function 'main':
/tmp/BlXEG8NqhU.c:6:15: error: expected identifier or '(' before '&' token
6 | const int &a = 2;
so the int &a = 1;
is that right?
a is a bias name of "1" in rodata?
|
|
|
|
|
I suspect that whatever QT Creator is doing is somehow creating a const reference . e.g.
int &a = 1; const int &b = 2;
Consider what int &a = 1 means: I.E. create a reference to the integer 1. If that were to compile successfully then consider
int &a = 1;
a = 2;
std::cout << 1 + 1 << '\n'; By the rules of C++, at least as I understand them, that should print 4, since you've changed the value of 1 to 2 at the assignment statement.
Keep Calm and Carry On
|
|
|
|
|
You are trying to use a C++ construct in a C-language program.
|
|
|
|
|
is a floating point number still considered a number? I`m talking about a number that is not whole. Like for instance 0.01 feels like less than a 'number'
|
|
|
|
|
|
|
Victor, Richard thanks for your useful feedback.
views from an 'average' user.
|
|
|
|
|
You're welcome. That website is really useful for any mathematical issues.
|
|
|
|
|
|
There is the function `Sys_Milliseconds`:
<pre>int curtime;
int Sys_Milliseconds (void)
{
static int base;
static qboolean initialized = false;
if (!initialized)
{
base = timeGetTime() & 0xffff0000;
initialized = true;
}
curtime = timeGetTime() - base;
return curtime;
}
Used in time calculation in the Quake 2 main game loop implementation:
//...
oldtime = Sys_Milliseconds();
//...
while (1) {
//...
while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
if (!GetMessage(&msg, NULL, 0, 0))
Com_Quit();
sys_msg_time = msg.time;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
do {
newtime = Sys_Milliseconds();
time = newtime - oldtime;
} while (time < 1);
//...
}
I'm wondering about the usage of the `Sys_Milliseconds` at all. What's the point in `base = timeGetTime() & 0xffff0000` line? Why are they applying the 0xffff0000 mask on the retrieved time? Why not just use the `timeGetTime` function directly:
oldtime = timeGetTime();
while (1) {
while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
if (!GetMessage(&msg, NULL, 0, 0))
Com_Quit();
sys_msg_time = msg.time;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
do {
newtime = timeGetTime();
time = newtime - oldtime;
} while (time < 1);
}
|
|
|
|
|
Member 15212768 wrote: What's the point in `base = timeGetTime() & 0xffff0000` line?
To avoid being too close to rollover point. From "timeGetTime function | Microsoft Docs"[^]:
Quote: The return value wraps around to 0 every 2^32 milliseconds, which is about 49.71 days. This can cause problems in code that directly uses the timeGetTime return value in computations, particularly where the value is used to control code execution. You should always use the difference between two timeGetTime return values in computations.
Mircea
|
|
|
|
|
Thanks to parallel processing these days you can feed in your game loop a constant value as time variable. (there is no fluctuation between frames as far as time is concerned). You should care about Frame Rate Independent movement only if you`re developing a game meant to hit the store shelf.
modified 5-Jun-22 2:07am.
|
|
|
|
|
Hello!, this is my first post on this forum and i'm trying to understand how this works, so if this is not the proper way of asking for help or this is in the wrong subforum just let me know please!
I'm currently studying App Development, and as sort of a "final project" to pass the course, me and my group have to make a proyect that tracks both users and their data consumption.
Since we're restricted to using codeblocks and c language, I wanted to get some insight on how to improve the visual aspect of the cmd, and user experience overall.
I havent found many content of this kind online so any tutorial or explainatory about this subject would be very helpfull, since we havent been taught too much about this side of the coding, and I think this will be a great adition to the proyect, and learning experience overall.
Thanks!
|
|
|
|
|
|
Thanks for answering!
The project has to be fully working on our teacher's computer, so no plugins or external libraries are allowed, whatever resources we can use has to be already installed on CodeBlocks, GNU Compiler vanilla version. Also this is our first proyect so any tips on this matter would be wellcomed .
|
|
|
|
|
Sorry, but without some actual problem details there is nothing much we can offer.
|
|
|
|
|
This seems like a question that should be easy to find an answer to, but I'm not finding anything very convenient...
What I will want to do with this, is to be able to right-click on a folder in Explorer, and have an item "run my program on this folder" available...
I've found two example programs which do this, but each have drawbacks for my application;
1. one is a C# application (which I'm not familiar with, though it *is* pretty similar).
Also, this CodeProject application is using registry modification to do the job; I would prefer to find a link somehow to the Explorer menu, then use InsertMenuItem() from WinAPI to add a link to my application...
2. that brings me to the second example that I found; it's in an older Platform SDK, in a utility called Shell\SampView... that application *does* do what I wish; however, that application is over 8500 lines long!! I am hoping to find a more concise solution to the problem...
Can anyone provide any guidance or example code for this??
I use C++, and build with the MinGW (32-bit) toolchain...
and yes, I realize that once I get *this* issue resolved, I'll still have a variety of other issues to resolve, such as finding the path to my application, and dealing with selection of wrong items (ideally, perhaps just grey out my menu item if the target is not a folder), and many other things, but for now, I just want to find a concise, clear solution to this one problem.
|
|
|
|
|
|
Okay, I don't have any problem with the Registry API functions, I've used them before.
I just expected that ShellAPI would be a more conventional way to do this; something similar to what is done with setting desktop icon colors, where we start with:
HWND hwnd = FindWindow("Progman", "Program Manager");
hwnd = FindWindowEx(hwnd, NULL, "SHELLDLL_DefView", "");
hwnd = FindWindowEx(hwnd, NULL, "SysListView32", NULL);
[ error handling omitted for clarity ]
to gain access to elements under Program Manager...
For one thing, the ShellAPI process would eliminate issues with permissions, which I might have with Registry access..
Anyway, I'll look into the links you've mentioned, and try those out.
|
|
|
|
|
If you depend on your application code making those changes, your app would have to run first before being able to use the Explorer context menu. Your code would also have to remember to remove those changes when it closes or upon uninstall.
Doing it through registry pokes eliminates those problems and makes them permanent until uninstall, which can be handled entirely in the installer, not your code.
|
|
|
|
|
That's a good point...
for most situations that I'm thinking of using this tool, I wouldn't be removing the link once it was installed; it would be for situations such as "open this file in MyEditor", or "run MyUtility on this folder"... but yeah, initially creating the link has to be considered, in either case; My plan was to check for existence of my link when running the program, likely in WM_INITDIALOG.. if it's not there, create it.
I mostly write small utilities, so don't always use a dedicated installer...
|
|
|
|
|