Click here to Skip to main content
15,392,679 members

Comments by Rick York (Top 200 by date)

Rick York yesterday View
I tried to correct the formatting but there is so much code missing I decided not save what I did.

One recommendation : learn how to write the sorting as a function because that code appears twice.
Rick York 4 days ago View
You have stated your problem. What is your question?
Rick York 29-Jul-22 15:59pm View
My advice is to use a debugger. We could try to help with that but there is not enough code here to build an executable image.
Rick York 29-Jul-22 13:55pm View
Good point - 100K loops is not infinite but it's close enough. Especially for a user who might be trapped in that loop.
Rick York 23-Jul-22 12:37pm View
Because visited is a two dimensional vector - a vector of vectors. That means each row is a vector also so vectors must be pushed into the vector.
Rick York 22-Jul-22 0:27am View
That initializes a vector of five integers with a value of 0. There are other cleaner ways to do that.
Rick York 21-Jul-22 1:43am View
Either put the prime numbers into an array or determine if a number is prime on the fly. With a decent algorithm, performance should not be an issue.
Rick York 18-Jul-22 11:15am View
The only real difference is there is no guarantee of the order of evaluation of the functions with && operators while there is with the nested conditional expressions.
Rick York 15-Jul-22 21:57pm View
I got it to compile with VS19 but I don't recall actually using it anywhere. The one I always use is a modified version of CReportCtrl by Bin Liu. I changed it to derive from CMFCListCtrl and a custom class by me.
Rick York 7-Jul-22 19:49pm View
As as I know it would be but I don't use OS-X or SDL. Usually header files do not affect linking unless they have pragmas that define the libraries to link with. This problem is usually caused by not specifying the correct path to the library files.
Rick York 5-Jul-22 16:36pm View
I think that message means there is problem linking. This is often caused by not correctly telling the linker where the library file is.
Rick York 28-Jun-22 16:43pm View
They are all acquired via scanf.
Rick York 22-Jun-22 23:44pm View
We can't find a mistake in code we can't see.
Rick York 22-Jun-22 2:14am View
I use Visual Studio and with my code I always use warning level 4 and it would flag this with a warning. I recommend trying that for yourself.
Rick York 21-Jun-22 20:26pm View
I would be using a debugger to solve this problem. It should show you exactly what is going on.
Rick York 8-Jun-22 3:42am View
I showed you how in your previous question.
Rick York 8-Jun-22 2:59am View
I showed you how in your previous question.
Rick York 4-Jun-22 0:20am View
Rick York 2-Jun-22 21:08pm View
If it's testing creativity then YOU should be the one who creates your idea.
Rick York 2-Jun-22 13:30pm View
Nope. That's your job.
Rick York 2-Jun-22 13:29pm View
This is NOT a solution and should not have been posted as one.
Rick York 26-May-22 0:50am View
Your solution does not satisfy the requirements because it does not override the < or > operator. I gave you two pages to read on that topic if you need information on it.
Rick York 21-May-22 13:48pm View
A console WILL handle a large volume of text. I have done it myself with dozens of process and four or five consoles, each having a buffer with 9999 lines of text and the systems runs non-stop.

Since you are running on a Windows OS, (32-bit FFS), the Windows SDK is your ONLY option if you are going to do something so hair-brained as sending strings to WordPad. Its source code is available so have at it. Who are we to dissuade you from that?
Rick York 20-May-22 20:00pm View
"You assumed that I might want to go from C++ to a crippling almost anti-coding platform like Visual Studio."

That is the most ridiculous statement I have read in a long, long time.

He was exactly right - using an external program in this manner will add in an incredible amount of overhead and is an absurd thing to even attempt.
Rick York 20-May-22 15:56pm View
That looks java but you tagged your question as a C++ problem.
Rick York 17-May-22 16:50pm View
There might be limit for data on the stack but in windows programs the stack usually defaults to 2MB so a limit of 12KB makes little sense. The OP has amended their post to state that WriteProcessMemory has a limit. That was not there originally and I seriously doubt that statement also. The documentation for that function does not state any limit and I think it is because there isn't one. I think the OP hasn't posted enough code for anyone else to make sense of. I know for a fact that what I showed WILL work because I have done it several times.
Rick York 14-May-22 12:34pm View
Have a look at the functions toupper and tolower.
Rick York 14-May-22 12:30pm View
Most prime number checkers start with 2 and then test 3 and then they skip by two. This is because 4 and the rest of the even numbers have already been tested. This means only the odd numbers need to be checked after two is tested.
Rick York 8-May-22 17:35pm View
If you want get fancy with it, you can implement an object factory as a static method of the Shape class. It's purpose would be to create objects of the specified type. That would eliminate all of those ifs in the user code and move it into the factory and they would appear in only one place - where the object is created. Using that would look like this :
cin >> index;
Shape * pobj = Shape::CreateShapeObject( int index );
delete pobj;
With virtual methods for all aspects of your requirements, the code to use them could be this simple.
Rick York 8-May-22 17:29pm View
Another tip : see the chain if statements in your main function? Add a method in every class to perform those operations. You could call it PromptAndCompute or something like that. Then you code looks like this :
if( n == 5 )
    Sphere obj;
Rick York 8-May-22 17:23pm View
One tip : consider making the Shape have virtual methods that the derived class all override or provide implementations for in the case of a pure virtual method. The Shape method would be the primary interface to users of the class(es).
Rick York 2-May-22 23:29pm View
No, that's your job.
Rick York 28-Apr-22 20:11pm View
I prefer to read text from a file into a string using fgets and then I use sscanf or strtok to extract data from the string. That way I know immediately if the end of the file is reached. Generally, I avoid scanf and fscanf.
Rick York 23-Apr-22 16:40pm View
Please consider learning how to spell the word "please."
Rick York 19-Apr-22 11:25am View
Do you have a question? If your question is, "will do my work for me?" The answer is NO!
Rick York 15-Apr-22 1:08am View
Someone else asked this same question recently. At least they could spell the word please correctly.

Nope. Ain't doing your homework for you and neither will anyone else here. Homework assignments are not emergencies.
Rick York 14-Apr-22 20:46pm View
That code is a mess. You should format it properly.

Also, why don't you know what the output is? My guess is because this is your homework and you should do that yourself. You will not learn anything if other people do your homework for you.

Helping people is one thing. Doing their work for them is entirely different. We are here to help you, not to do your work for you.
Rick York 14-Apr-22 13:25pm View
Rick York 13-Apr-22 12:30pm View
I prefer a more generic hash table organization which for this one means id is replaced with a pointer to this person's "List" structure. The members of the structure would be :
typedef struct _HashItem
   char * key;
   void * pData;
   struct _HashItem * pNext;
hopefully that resembles C syntax. Anyway, it's essentially the same as what you have but it can work with practically any data.
Rick York 12-Apr-22 21:00pm View
You have used the literal value 27 in many places. That is a very, very bad idea. You have made it a definition like the other constants and you should use it - MDIR.
Rick York 12-Apr-22 21:00pm View
You have used the literal value 27 in many places. That is a very, very bad idea. You have made it a definition like the other constants and you should use it - MDIR.
Rick York 11-Apr-22 20:07pm View
FWIW, nothing about my algorithm is recursive. It uses a weird counting method I figured out for handling permutations. For this, it uses a vector of twenty-four counters that work with base 6 values. This allows it to use loops without recursing. I am going to see how it does with 16 digits and a target sum of 63 next. That should be interesting.
Rick York 11-Apr-22 14:34pm View
I tried something a little different. I changed the number of digits to 12 and the sum target to 42, both half of the originals. This gave results that won't take an entire day to evaluate :
tests checked : 2,176,782,336
total matches :   144,840,476
elapsed time  :        12.222
the time is in seconds.
Rick York 10-Apr-22 21:30pm View
I wrote a program to solve them. It ran for an hour and this is the last one it found : 29,480,000 : 111111111565415656666554. I didn't feel like letting it go for several more hours. There are going to be around 200M solutions in total I think.
Rick York 10-Apr-22 18:49pm View
Aren't there 6^24 possibilities? That's 4.738E18. Of course, not all will sum to 84.
Rick York 31-Mar-22 10:54am View
What is the error message you receive?
Rick York 18-Mar-22 15:35pm View
Did you read what I wrote? I will repeat it : "You can take at least two approaches to the bitwise algorithm : either shift the data or shift the mask." You shifted the data, this solution shifts the mask. This was solely to present another option.
Rick York 18-Mar-22 10:53am View
Performance-wise that is the worst possible option. I avoid bit fields when ever possible.

The question is about determining patterns in the bits. This shows how one can find out what the bits are.
Rick York 12-Mar-22 12:50pm View
I consider it much better to write :
cout<<"Select an option\n";
cout<<"2.Change Account type\n";
cout<<"4.Change Name\n";
cout<<"5.Display Details\n";
Rick York 12-Mar-22 12:46pm View
displayMenu does not access any member variables.
Rick York 10-Mar-22 12:16pm View
Brute force is the appropriate thing to try in my opinion. There appear to be only eight possibilities so it's really not so bad. That is, four columns combined two at a time.
Rick York 10-Mar-22 0:00am View
Have you considered using the Spy utility and finding out for yourself exactly what messages are sent?
Rick York 28-Feb-22 22:40pm View
That is a rather low precision value for pi. You can get a better one by including math.h and preceding it by defining _USE_MATH_DEFINES :

#include <math.h>

const double desired_pi = M_PI;
Rick York 25-Feb-22 21:19pm View
Partly because you do not have logic to display output for every possible input.
Rick York 24-Feb-22 20:55pm View
Do a search at the site of your preference for "linked list." You should find several million possibilities including a few at this site. That should tell you how to implement a linked list. This YOUR problem so you need to do the work.
Rick York 21-Feb-22 23:35pm View
Coding in between what?
Rick York 15-Feb-22 18:38pm View
I am curious: of what value is timing code running in a debugger? I have been writing software for a long time and have never once considered doing this.
Rick York 15-Feb-22 18:36pm View
How is this relevant for C code?
Rick York 11-Feb-22 1:08am View
Do you have a question?
Rick York 10-Feb-22 20:46pm View
You don't need to run dumpbin on the target machine. You need to run it on your development machine and then take note of the libraries that are referenced. You can redirect the output to a file and then analyze the results however you want to.
Rick York 9-Feb-22 18:07pm View
This is good advice.

dj4400: if you don't want to use that program Visual Studio comes with something called "dumpbin." You can use it with the "/IMPORTS" option and it will tell you all the DLLs you are trying to import. This works with both DLLs and executable files. You might have to transfer it over to your target machine since it's not a built-in utility.
Rick York 8-Feb-22 11:19am View
Writing a bunch of code for someone does not help them learn anything. They need to do at least a little thinking if they are going to learn.
Rick York 5-Feb-22 1:28am View
Then enter different values when you run the program.
Rick York 4-Feb-22 13:08pm View
This can help :
Rick York 3-Feb-22 22:19pm View
If you can, you should turn the warning level up because this mistake is caught automatically when it is set high enough. I use Visual Studio and always have the warning level at 4 and warnings are errors and it always catches this error.
Rick York 1-Feb-22 11:17am View
Yes, I agree and that's what I would have done normally. It seems this poster is a beginner and I didn't want to get into access control with them at this point.
Rick York 1-Feb-22 3:29am View
Habit - I usually have separate specifiers for members and methods because usually members are protected or private.
Rick York 23-Jan-22 12:20pm View
You can declare it outside the loop but you must initialize it every time through the loop.
Rick York 20-Jan-22 13:17pm View
I often replace backslashes with forward slashes for similar reasons. The thing is the OS and API can handle forward slashes just fine. They work exactly like backslashes. From what I've found the only thing that doesn't handle them correctly is the windows command prompt. It thinks forward slashes are argument delimiters. So, while you don't have to replace them, you can if you want and I usually use a loop around the strchr function to do it. It returns a pointer to the first occurrence of the specified string so it's a simple matter to replace that with a different character.
Rick York 19-Jan-22 15:35pm View
Yes, I can, but I won't. I make it a point to never help someone who can't be bothered to correctly spell the word please. That's almost, but not quite, as annoying as people who are so sincere with their gratitude they write thx.
Rick York 19-Jan-22 11:54am View
You can install toolsets with the Visual Studio Installer. Click the Modify tab and then select all toolsets and SDKs you want to install. It's a fairly simple procedure.
Rick York 19-Jan-22 11:28am View
That does not look at all like C to me and it appears to have very little to do with your problem.
Rick York 18-Jan-22 17:38pm View
In C the binding of the minus sign with the value versus considering it an operation is a matter of precedence. That means you have to either implement precedence in your calculator or do something like require spaces to separate the values and operators.

I don't consider this a solution because I can't tell you how to implement precedence.
Rick York 17-Jan-22 16:12pm View
It is certainly possible for us to assist you but assistance is not the same as writing this for you. That we will NOT do. At least, I won't. I will be happy to help you overcome any issues that arrive but I will not write your program for you.
Rick York 15-Jan-22 12:53pm View
Why? There are plenty of libraries available so what's the point?
Rick York 14-Jan-22 11:55am View
Here's an optimization I often use: the sqrt is one of the most expensive math functions there is and multiplication is much faster. Also - never, ever use the pow function to square values because it is even more expensive that sqrt. Make a template function to square values instead. Anyway, the optimization is if you want to compare with a given distance - square that distance and compare it with the sum of the squared differences in point coordinates. It's essentially the formula you are using except no square root is used. I have seen tremendous performance gains with these two simple things.
Rick York 12-Jan-22 12:04pm View
In general, a vector is not a good container to use if deletions of this nature are required. A list is better if this is necessary.
Rick York 8-Jan-22 12:24pm View
You have the answer but it is important to note that the arguments are not required to be of the same type.
Rick York 7-Jan-22 11:09am View
The function atoi can do it.
Rick York 6-Jan-22 11:07am View
That declaration has a problem. There are two rows of strings, each four characters long. The string "apple" occupies six characters (with an added null) and "milk" takes up five. The strings need to be bigger, at least six characters long.
Rick York 5-Jan-22 18:15pm View
One can call GetProcessInformation :, with that handle. The startup information, for the most part, is available by calling various functions using the process' window handle, if it has one. STARTUPINFO is described at :

Exactly what is misleading about that answer?
Rick York 5-Jan-22 12:11pm View
You are contradicting yourself. You stated you did not need to start the process and now you have stated you are calling NtCreateProcess. The answer to the question is considerably different depending on this point.
Rick York 4-Jan-22 2:59am View
You should include the code for the compute function also along with the definitions of the TOP, BOTTOM, LEFT, and RIGHT values.
Rick York 3-Jan-22 12:19pm View
Since you are writing in binary mode why do you need to? Just flush your data and rewrite the file and it's done.

BTW - I never, ever use binary files and I can't remember the last time I did. The reason is they cause much more headache than they are worth as far as I am concerned. Disk space is cheap so there is no good reason for them in anything I do.
Rick York 2-Jan-22 14:46pm View
That could make your logic look like this :
wx = ( thick - 1 ) * sqrt( Square(x2-x1) + Square(y2-y1) ) / ( 2*fabs(y2-y1) );
Rick York 2-Jan-22 14:44pm View
If you are concerned with performance then you should never use the pow function to square a value. Internally it use a logarithm and exponential operation so it is very, very inefficient for this purpose. If have to you draw lots of lines it will become noticeable. Instead, use something like this template function :
template< typename T >
inline T Square( T a ) { return a * a; }
Rick York 31-Dec-21 13:48pm View
That's closer but it will build the string backwards. Also - i is not initialized.
Rick York 31-Dec-21 13:47pm View
No, it does not. That's why I was very hesitant to add code. In the end I decided to do it because they can't debug the code until it compiles.
Rick York 29-Dec-21 19:58pm View
It's not that you can't use them. You asked how to make your code more efficient and that is the answer - use something besides regular expressions. What you need is a non-destructive tokenizer. A function like strtok is destructive so it is not appropriate for this. At least, that's how I would approach it.
Rick York 28-Dec-21 12:59pm View
This should have been a reply to Richard's comment which is accurate. WaitForMultipleObjects is probably the one that should be used. It takes an array of objects than can hold 64 items in a 64-bit Windows OS. This really does work and it works quite well. I implemented a subscription service for a thread pool using this mechanism and it works great. Windows supports a variety of signal-able events that you can wait on. If you use named objects they can even be controlled by different processes which is what I do.
Rick York 26-Dec-21 0:55am View
Why is M_PI defined? You do not use it in your code and it is already defined in math.h. It certainly does not need to be defined again.
Rick York 24-Dec-21 11:38am View
You are including math.h so there is no need to define M_PI because it is already done in math.h. You can add the definition, #define _USE_MATH_DEFINES before including math.h and you will get all of the math definitions enabled like M_PI, M_E, etc.
Rick York 22-Dec-21 12:39pm View
I just noticed you need lower case letters also. That means the GetRandomChar function needs to be changed. Since you can't be bothered to respond, I will leave that to you.
Rick York 20-Dec-21 16:25pm View
One of the above. Do you really expect us to do your homework for you?
Rick York 19-Dec-21 14:24pm View
Change where you start and end the loop then. You could make this a separate function and pass in the string to check. The loop can stop when you hit a space or a null and then start again after the space. That's why it might be easier if that logic was in a separate function that you pass the address of the string to. That allows you to put the logic for separating the words outside the loop.
Rick York 16-Dec-21 19:58pm View
If this is a coding challenge then you need to figure it out yourself.
Rick York 16-Dec-21 19:56pm View
It is best to edit your original post and add a note to it stating that you have updated the code in the post.
Rick York 16-Dec-21 11:04am View
The general term used for this is "plug-ins." Applications define an interface for DLLs and their functions to adhere to and the app can dynamically load plug-ins and use their interface.
Rick York 15-Dec-21 23:58pm View
It's a puzzle - let's see if he can fix it. :)
Rick York 15-Dec-21 23:57pm View
You are progressing if you can see the errors - or did the compiler tell you? :)
Rick York 15-Dec-21 1:54am View
If you are just squaring values I recommend against using the pow function to do that. It is very inefficient for that purpose. It would be better to write a square function and call that. It can be inline or templated so it will be much faster. The pow function uses a logarithm, an exponential function, and a multiply whereas a square function will be a single multiply and that's all. The pow function is made that way because it needs to deal with real exponents. If you only use integer exponents then a custom power function would be a better option. I made myself square and cube functions because those are as high an exponent as I ever work with.
Rick York 14-Dec-21 16:24pm View
We are happy to help you fix problems with your code but we are not here to write it for you. You will learn nothing from that.
Rick York 14-Dec-21 15:55pm View
You have defined your serial NUMBER format but you have not defined what you want or need to do with it.
Rick York 11-Dec-21 12:58pm View
Your problem was that you can not modify the memory you passed to the function - it was read-only or constant. The revised code passes memory that IS modifiable or non-constant.
Rick York 10-Dec-21 17:01pm View
There is no difference between them but that's not issue with your code. The issue is you can not modify read-only memory.
Rick York 9-Dec-21 20:46pm View
Oh, it's urgent? I hope you learn that procrastination is not in your best interest.

My general rule is the more urgent someone needs something, the less interested I am in helping them.
Rick York 8-Dec-21 16:15pm View
I think the point is to have some data about each student the file and read the file and store the data. You need to decide what data to have in the file. Examples are last name, first name, identifier, and birthday. You could use commas to delimit each data item.
Rick York 8-Dec-21 16:12pm View
You have not included the code for Spinner.h. The code for main.cpp was included twice.
Rick York 8-Dec-21 16:10pm View
OK, help you with what? You have not actually asked a question.
Rick York 7-Dec-21 18:08pm View
Look at the implementation of voltage_divider_Calc(). It acquires input for three local variables and then it does nothing with those values. The voltage object has its get_Vout() method called but the object's members are not set to the values that were input.
Rick York 6-Dec-21 11:43am View
I have a question for you : do you consider it better to return a vector of strings from the function instead of passing a reference to the vector as an argument to the function or are they essentially equivalent? With move semantics I can see how there would be little difference but I tend to prefer to pass a reference.
Rick York 5-Dec-21 15:25pm View
You should probably find a definition of "anonymous activity." There are a lot of possibilities. This is important because you need to know what it is your program is supposed to detect.
Rick York 29-Nov-21 12:06pm View
OK, so use the data like that. A window can get its index into that vector as I showed you. I would make a class to contain the data and a method to get an index and/or pointer to a window's data. Here is a prototype you could use : Data * GetWindowData( HWND hwnd ); You can wrap all of this stuff up into one easy method call. There could be a corresponding SetWindowData method also.
Rick York 27-Nov-21 14:01pm View
One recommendation for you: look at a header file called WinNT.h in the windows SDK. There is a structure there called _LIST_ENTRY and it is nothing more than pointers to forward and backward links. There is then a series of macros used to manipulate the list and its contents. This is done in an entirely generic way and I suggest you take some suggestions from it. Primarily that you shouldn't build lists that are specific to their content. You should build a generic list class with methods to deal with the content. This way you have one set of code to manage a linked list and it can contain any kind of data you want to. This is easier with templates.
Rick York 25-Nov-21 13:42pm View
The problem with rand is it is limited to a range of 0 to RAND_MAX which is usually set to 32767. A combination of rand with the time value and some scaling might give a more random result. I once did an experiment where I needed to generate 4B unique values. I ended up using the mersenne_twister_engine, std::mt19937_64 as the PRNG and std::uniform_int_distribution. I saved all 4B values and verified there were no matches. I ran this test many times and never found a match. It worked out pretty well.
Rick York 20-Nov-21 22:16pm View
I think using threads for this is pointless overkill.
Rick York 19-Nov-21 0:21am View
If you change the static initializers it will run. I think it is very import to add the player number and the created counter so you can see who is doing what. Without them you can only guess. The created counter gives every player a unique number regardless of how many die. I recommend you adjust your code to be closer to what I did so you can see what's going on.

BTW - I adjusted the code to use an actual string and it gives the output I would expect.
Rick York 18-Nov-21 0:51am View
Your question is unclear. Can you use an STL collection like a std::list to hold the items? Do the three items you listed have to be dynamically-sized or can the be static items? All of these things matter to how it is implemented.
Rick York 17-Nov-21 22:27pm View
I have suggested that line numbers be added a few times but there seems to be little interest. Almost other code-oriented site I visit has it but this one does not.
Rick York 17-Nov-21 21:45pm View
BTW - this same code will accept input from the command line or by reading the file. I use the input redirector to have the program read the file. I did this by typing "ConsoleProgram < InputData.txt" in a command window.
Rick York 17-Nov-21 1:33am View
What's in it for us? You undying gratitude is inadequate.
Rick York 14-Nov-21 13:18pm View
That is interesting. I began doing things this way for purely philosophical reasons. One of those philosophies being that not every source code file needs its own header and I now go out of my way to make sure they do not. I have become a huge fan of opaque pointer interfaces and it has simplified things A LOT for me. As an example, I write mostly code for windows and the vast majority of dialogs I use do not have a header file. Since they nearly always are editing or just displaying a batch of data, I declare a prototype function to edit or display the data with the header that defines the data. The internal details of the dialog are not needed by any other code so there is no need for it to have a header file. I take a similar approach to most things in an application and this has simplified things for me immensely.
Rick York 14-Nov-21 13:11pm View
This page lists all compilers that support it and there is only one on the list that does not : the IAR compiler.
Rick York 13-Nov-21 17:40pm View
Your code would almost compile if you got rid of all the question marks. Also, indentation is your friend.
Rick York 10-Nov-21 20:10pm View
That is your teacher's question. What is YOUR question? For you to repeat the problem tells us that you want someone to do your work for you. That is not the purpose of this Q&A forum. We are here to help you with YOUR code. We are not here to write it for you.
Rick York 10-Nov-21 15:23pm View
What is your question?
Rick York 8-Nov-21 0:01am View
It's just another form of branch. I'm sure you can figure it out.
Rick York 6-Nov-21 0:57am View
I recommend that have you a look at the Related Questions list on the right of this page. Also consider searching this site for articles on the topic of sockets. There are a good number of them.
Rick York 2-Nov-21 16:06pm View
You have assumed everyone who reads your question knows what the acronym SFS means. It is much safer to assume that no one does.
Rick York 30-Oct-21 15:04pm View
That you for the corrections.
Rick York 27-Oct-21 20:22pm View
It is easy to cause problems like memory leaks with multiple return statements but if you always use automatic objects it is not an issue. Things like unique_ptr and vectors are very useful for preventing leaks. I use Visual Studio's tools for memory tracking and they are pretty good. I wrote this tip on the topic :
Rick York 27-Oct-21 17:27pm View
That might work but it has serious limitations. I have revised my solution to show you what it should be more like.
Rick York 25-Oct-21 15:06pm View
I wouldn't worry about it. I would try it and find out and then deal with the results.
Rick York 25-Oct-21 11:56am View
If your program is waiting for input then it is usually best to output a message saying so. In your case, it should write, "Enter x value : " or something similar when it is waiting for x to be entered and something like that when it is waiting for y to be entered.
Rick York 23-Oct-21 14:26pm View
What is your question?
Rick York 20-Oct-21 16:00pm View
I do this for both mine and others. Lots of people like cmake these days but I just use VS19 projects. I find that it's usually not very difficult to build a project for most libraries. I did this for a few third-party libraries just last week. For the most part, it was just a matter of getting the definitions straight. As long as there isn't any weirdness in the build process this is fairly straight-forward. VS19 supports pre and post-build options so most weirdness can be accomadated.
Rick York 20-Oct-21 3:41am View
It could make for an interesting experiment to see where the break-even point is between using a map and a linear search. I would probably use a different set of strings than the three you have. I found a list of over 460K words and I would probably use a random set of them for a test like this. I might just do this if I get some time soon.
Rick York 16-Oct-21 19:33pm View
The function strdup is handy for this.
Rick York 16-Oct-21 19:32pm View
Do you realize that your file reading code will not allow song titles or artists to have spaces in them?
Rick York 15-Oct-21 15:40pm View
OK, change it to print the entire tree then. I will revise the solution to have a modified printNode function. This should help you see what's going on a little better but the debugger is usually the best way to do this.
Rick York 14-Oct-21 18:42pm View
I have two recommendations for you. First, put your input data into a file and then run your program with stdin redirected from that file. The syntax for that will be something like "YourProgram < InputFile.txt". This will much easier than typing it all in every time. Personally, I forgo manual entry almost always and read files for input but that's just me. Second, have a look at the column titled "Related Questions" on the right of the page. This question has been asked before so some of the previous answers might be helpful.
Rick York 14-Oct-21 17:51pm View
I showed you what was wrong and how to correct it but since it is obvious you don't want that you can't have it.
Rick York 13-Oct-21 12:17pm View
In my opinion, treating the data as a 1D array is a mistake. I think you should make it a 2D matrix. That would likely require you to figure out how to allocate a 2D matrix and that is a good thing. It is really rather simple. First allocate an 1D array of pointers to integers for each row and then fill in each slot with a 1D array of integers for the columns. The process is reversed for releasing the memory.
Rick York 9-Oct-21 12:03pm View
You can also use calloc which will zero the allocated memory so the terminating null character is there automatically.
Rick York 8-Oct-21 16:26pm View
NOT! including a source code module in another one defeats one of the primary reasons to have code in separate modules. That would be to improve build times. One should only have to recompile the module(s) that changed. If you only changed human_functions.cpp then you should not have to compile anything else. This is far less an issue now than it used to be but, regardless, that is not recommended practice.
Rick York 6-Oct-21 22:30pm View
Do you have a question?
Rick York 3-Oct-21 13:35pm View
Your question is not at all clear. What does "how would one go about combining the print line function with the table below?" mean? This is unclear because one does not "combine" a function with a printed table. Actually, from what I can see, the output you show there was not generated by your code because that's not what your format string does.

To reiterate, what are you actually asking?
Rick York 3-Oct-21 1:08am View
One other thing : the (pseudo) random number generator should be seeded first. This can be done calling
    srand( 47 );
Generally, it is best to seed with a prime number. Using a constant value like this will give a repeatable sequence of values. Meaning every time you run the program you will get the same sequence of values. If you want a unique sequence of values every time then do this :
    srand( time(nullptr) );
Rick York 3-Oct-21 0:13am View
You already have them. What's the problem?
Rick York 2-Oct-21 20:45pm View
If I am not mistaken, the asm keyword is not supported in Visual C++ 64-bit code. If that environment is not one of your targets then this is irrelevent. :)
Rick York 2-Oct-21 0:28am View
I am not going to give you answer but I will give you hint. Start by analyzing the pattern. With an input of 5 you get the following output :
row 1 - 5 items and they increment by 1
row 2 - 4 items and they increment by 2
row 3 - 3 items and they increment by 3
row 4 - 2 items and they increment by 4
row 5 - 1 item - the input value
The pattern should be obvious.
Rick York 29-Sep-21 16:05pm View
Definitely! I still use MFC and never, ever use its containers.
Rick York 22-Sep-21 13:13pm View
My initial understanding of createTree was incorrect. I can see that it does what you want to but I would most definitely NOT call it "completely correct" and I find it difficult to believe that a teacher would. As KarstenK mentioned, you should return the first element of the array (item 0) and the loop should be for( i = 0; i < 11; ++i ) and that means the rest of that function should be revised accordingly. In C and C++ the first item of an array is [0]. You need to get in that habit now or it will cause you lots of problems as you progress.
Rick York 20-Sep-21 18:16pm View
If at all possible, I would try to avoid that because it exposes higher level code to details it probably does not need to know.

FWIW, I am in the automation business and I have been making interfaces to hardware for decades and I have found it enhances the usability and reusability of an interface when as few details as possible are known.
Rick York 20-Sep-21 16:55pm View
I don't have solution but this is where I would fire up the debugger and figure out what's going on. That is, assuming you can get that code to compile. What you have posted will not.
Rick York 19-Sep-21 19:57pm View
I find the using statement to be very helpful. For this, it could be something like this :
using mapintstring = std::map< int, std::string >;
Rick York 17-Sep-21 19:44pm View
Thanks for trying that. I don't have access to a Linux box so that was helpful.
Rick York 17-Sep-21 14:08pm View
Where you call srand, instead use the first three lines to initialize the RNG. The last line shows how to call it. The function rand has a maximum return value of RAND_MAX. With this code it has a maximum of highestValue so if you can still use the modulus of the length to get the RV and you can use almost whatever you want for highestValue - RAND_MAX if you want.
Rick York 17-Sep-21 11:21am View
You are using two global variables : A and A2. Those do not need to be global. They can and should be local to your main function.
Rick York 16-Sep-21 11:40am View
Have you noticed the fact you have the value 6 hard-coded quite a few places? What would happen if your teacher decided you need to check 8 values? The answer is NOT change all 6s to 8s. The answer is to make the number of items a constant value and define it in ONE place and pass that as a parameter to functions like Percent and everywhere input and/or output are done should be loops.
Rick York 14-Sep-21 12:56pm View
There is a good probability that there is nothing you can do to your program that would make any difference to this issue. Your best bet might be to add the programs that were deleted to a "white list."
Rick York 3-Sep-21 3:50am View
Nope, this is YOUR home work. I already did mine.
Rick York 2-Sep-21 13:57pm View
What question?
Rick York 1-Sep-21 23:38pm View
YOU need to write it in c++. We are not here to do your homework for you.
Rick York 1-Sep-21 11:37am View
This is precisely what screen savers were intended for. The one caveat is you have to teach people how to wake them up appropriately. What that means is tell them not press OK or space or click a mouse button. Doing those things can have unexpected effects. The correct way to wake it up is to either move the mouse or press the Shift or Control keys. All of those are safe things to do.
Rick York 31-Aug-21 15:47pm View
You had better get cracking or you are likely to fail your class.
Rick York 29-Aug-21 18:37pm View
This is actually a repeat of a previous question but this one is much less specific.
Rick York 29-Aug-21 12:38pm View
See this documentation :
Rick York 28-Aug-21 14:16pm View
Peter is correct. You can't do that. What I wonder is why you would want to. Two function pointers use a very small amount of memory so why would you want to dynamically allocate that? You will use just as much if not more memory in the allocation table for that entry so what's the point? I recently wrote a thread event handler dispatch mechanism which was a table of 64 entries and it was not dynamically allocated because a) there is no good reason for it to be and b) it can't be any larger than it is because a thread can wait for at most 64 objects at once in windows.
Rick York 27-Aug-21 11:20am View
One suggestion I have is lose the value 4344 which appears in your code three times. That should be an argument to the function or a constant value. It should NOT appear multiple times in the code.
Rick York 26-Aug-21 2:24am View
Writing the program is YOUR problem.
Rick York 22-Aug-21 12:32pm View
If you tell fwrite to write ten items it will return 10 if is successful.
Rick York 18-Aug-21 14:16pm View
This is not a code-on-demand site. We are happy to help you fix your code though. You need to write it first.
Rick York 17-Aug-21 18:10pm View
You have three opening braces and four closing braces. That can't be right.
Rick York 13-Aug-21 13:18pm View
Thank you.
Rick York 13-Aug-21 13:18pm View
I am not sure what "more cross platform than using ..." means. This technique can be modified to work on any platform with any type of objects. It's somewhat less useful on platforms that don't work like windows where various types of objects are selected to be active at various times.

As for using more CPU and/or memory : the class has three simple members that use less than 20 bytes on a 64-bit system and no new resources. That means very little memory use and there won't be enough CPU use to worry about.
Rick York 12-Aug-21 0:06am View
One possibility I have seen often is trying to draw to an invalid window or device context. Be careful to make sure they are all valid when you paint with them.
Rick York 7-Aug-21 14:02pm View
Have you tried catching the EN_CHANGE message and looking for the handle of the combobox's edit control?

I never use this kind of combobox so I am unfamiliar with it.
Rick York 6-Aug-21 15:23pm View
My suggestion for you is to learn the language and figure it out. The algorithm has been given to you so you need to figure out how to implement it. That's what programming is about - figure out an algorithm to solve your problem and then write code to implement it.
Rick York 3-Aug-21 16:30pm View
No, the array is not altered at all in the for loop. The pointer is incremented to step through the array.
Rick York 3-Aug-21 11:41am View
I doesn't really work that way. Storage is in units of bytes so if you only use three bits there is still a byte stored.

When shifting to make the mask the desired position is the "bit" parameter that was passed and it can range from 0 to 7.
Rick York 3-Aug-21 11:38am View
True. Templates are not particularly useful with the C language but if you think of them as essentially smart macros they can be adapted.
Rick York 2-Aug-21 4:48am View
Those braces can NOT be removed because they part of one of two name spaces - AK and AssaultRifle. Both are referred to in the code and one is likely to be wrong.
Rick York 28-Jul-21 23:32pm View
No, you may not have an answer. This is YOUR exercise so YOU need to figure it out.
Rick York 11-Jul-21 16:25pm View
You stated, "for it to be able to be converted from vector to vector<int>" Nowhere in your question did you describe what integers are to be placed in that vector. If what you want to do is find the index of an item, what does that have to do with a vector of integers? If you want to store a vector of the results of find_if then you do do not need an index because you can save a vector of iterators and access the items using the iterators much more simply. However, if you plan to delete items from a vector using the iterators then make sure you access them from last to first or else they will become invalid after the first deletion.
Rick York 10-Jul-21 21:13pm View
Yes, I am sure there is one.
Rick York 9-Jul-21 19:57pm View
You omitted one very important piece of information. WHAT "shows recourse file is not available" ? In other words, what is IT?
Rick York 26-May-21 22:40pm View
This website is about helping people solve problems with their code. What code do you want help with?
Rick York 26-May-21 4:14am View
You should edit your original question because no one wants to read code in the comments.

Also - you have <= for min. That is not correct. It should be just < and min should have just > as its comparison
Rick York 24-May-21 21:33pm View
I don't have an answer for you but when I run into problems like this I try first try to determine if there is an issue with the model or with the drawing. To do that I first try drawing a simple model like a cube, tetrahedron, or sphere. Usually it is one I define myself and I try to make it the same size as the one of interest. Once I see it displayed correctly then I try it with the other one.
Rick York 24-May-21 11:21am View
Yes, it is applicable. You are trying to receive a response and you don't know the port number - that's how to do it.
Rick York 23-May-21 14:23pm View
Do you have a question? Have you noticed that the function fact is never called?
Rick York 22-May-21 13:47pm View
Yes, I am certain someone can convert that code but why would they want to? What's in it for them? Your undying gratitude is probably not going to interest anyone.
Rick York 21-May-21 20:09pm View
thank you, sir.
Rick York 21-May-21 11:31am View
In C++, the using statement can be used to accomplish the same effect.
Rick York 21-May-21 11:30am View
While you're at it, you might want to include the cast in the macro.
Rick York 19-May-21 16:42pm View
Why are you using a long double? For a probability calculation it is entirely unnecessary. It's even more absurd when you are casting intermediate results to a float. That makes absolutely no sense to me.

What language is Math.Pow from - C#?
Rick York 19-May-21 11:38am View
Rick York 17-May-21 11:51am View
YOU need to do this work. Exercises like this is how you learn. We've learned this stuff so it is of no help to us. We also have no interest in enabling more inept programmers because there are far too many in the world already. The only way you are going to learn this is to do your own work. Converting someone else's work doesn't help anyone, least of all YOU.
Rick York 17-May-21 1:45am View
This is a good time to use a debugger since this is why they were invented. If you don't have access to one then starting putting in printf statements to show you what's going on. In fact, there's a whole style of diagnosing problems called "printf debugging." Sometimes you have to do what you have to do.