15,794,475 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Python questions
View PHP questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Stefan_Lang (Top 200 by date)
Stefan_Lang
31-Jul-22 6:32am
View
My five. Good code suggestions and good catch on that '\/'!
Stefan_Lang
18-Jul-22 8:51am
View
Sorry for the late answer. I've been disconnected for quite some time.
The short answer is no. Just to be clear, the software mentioned in this topic does not add any security, it only provides an API to access the dongle. You can think of it as a device driver. It's the dongle itself which provides the protection, as each is individually manufactured for this particular purpose.
However, if you're looking for software based protection, you could use an asymmetric encryption scheme, e. g. PGP ( see https://en.wikipedia.org/wiki/Pretty_Good_Privacy ) to achieve a good level of security.
Stefan_Lang
25-Jan-22 8:02am
View
indeed, i missed the '>' . Well spotted.
Stefan_Lang
25-Jan-22 7:51am
View
You should really post your question at the very beginning. The "What have I tried" section is the very last place anyone will go looking for it!
Moreover, most questions can be answered very quickly, if we can know what information to watch out for when reading the details. Not knowing what to look for requires reading the entire text, and that does cost a lot of time.
And every single person willing to help you out will have to go through all that! Why?? You are just one person, and it takes you a lot less time to provide the single most bit of information in your posting, than it takes one hundred people to scan your entire text for it!
This section is called "Quick" for a reason! Please help posting questions in a manner that can be answered quickly.
Stefan_Lang
24-Jan-22 10:07am
View
What is the question? That's a big wall of text, but no clear indication of the problem.
Stefan_Lang
23-Jan-22 10:12am
View
Actually, the while loop has a num++; statement right at the end. It's easy to miss because the indentation is wrong.
Stefan_Lang
23-Jan-22 9:58am
View
I'm not familiar with this algorithm, but I noticed you're printing integers without any separation in-between, and it seems these integers can be greater than 10.
Maybe you should try writing a space after each integer and find out if any of the numbers are indee greater than 10 (in cas this shouldn't happen), or if you are reading the output correctly.
Stefan_Lang
18-Jan-22 9:49am
View
I have already found that Wiki entry after posting the question, but it doesn't solve the actual problem: I have explicitely set these flags in a reasonable manner for my devs machine. But doing this caused undefined behaviour of the plugin on some machines it was deployed to!
I could not find any info on what these flags do with respect to deployment. According to the descriptions, there doesn't seem to be any relation. But the effect is clearly there! I had hoped for a better description of what these flags really do, but the only info I find is on how to set it to improve my build times. But build times is not my problem at all!
Stefan_Lang
11-Jan-22 5:27am
View
This is not a homework service, nor a cost-free work-delegation service.
If you have any specific question on a line of code or statement you don't understand, then ask a specific question. Anything else goes beyond the scope of this forum.
Stefan_Lang
11-Jan-22 5:23am
View
Do not assume that anyone reading your question is familiar with the specific methods you happened to have come across, or familiar with the specific names of these methods that you know, even if they do know the method as such. Methods and algorithms tend to be known by different names depending on your source. And not every source introduces abbreviations for such names at all. Therefore abbreviations such as DFS or DP are not helpful!
At the very least provide names that are concise enough to be googled, so the reader will be able to look up if it happens to be something he is familiar with under a different name.
Stefan_Lang
11-Jan-22 5:17am
View
1. Given how many abbreviations exist in various contexts, you would do well to actually use full names. I have no idea what you are talking about.
2. This may not be the right place to ask, unless you have a concrete issue where you don't know how to implement something with C++ or another programming language - QA is not meant to provide you with the 'something' part, because that would not qualify for the 'Q' (quick) in 'QA'
Stefan_Lang
9-Jan-22 5:46am
View
std::vector is the most important of the container classes. You can and indeed should read up on it e. g. here: https://en.cppreference.com/w/cpp/container/vector
As for factory methods, that is just one way of constructing objects in C++, but it is, in fact the one I find to be most useful.
The most common way to construct objects is using constructors with arguments like @merano99 suggested in the comment below. However, I prefer actual methods over constructors because they let you use a meaningful name for the function, and let you do some things that a constructor cannot do.
Stefan_Lang
8-Jan-22 20:49pm
View
Only with explicit keyword. You wouldn't want to accidentally convert numbers to Floor objects after a typo.
I personally prefer factory methods (or factory classes, depending on the complexity of the object), because you can name them properly, and can validate already constructed objects within the factory method before passing them onwards rather than relying on the caller to do so.
Stefan_Lang
8-Jan-22 17:51pm
View
I updated the solution to include the change I suggested (and a few more improvements). Note that I eliminated some functions that are no longer needed with the new approach.
Stefan_Lang
8-Jan-22 14:38pm
View
Only when you're not using an editor that can show you the type of an object just by hovering over the name. It doesn't confer any information. You may argue that using 'hotel' will make it less likely to introduce errors to your code, but modern editors and good code structure will prevent that kind of error anyway.
So, yes, it may be an improvement, but it's still a long way from a good name.
That said, I dislike names that are different from other names just by capitalisation (one reason why I hate C# naming conventions). It's too easy to mess your code up with a typo, and too hard to spot such errors to be worth not spending a second or two to find a better name.
Stefan_Lang
8-Jan-22 14:18pm
View
I'm not sure who downvoted you, but naming an object after the class isn't any better than using one-letter names. Of course in code like this there are rarely any meaningful objects, but e. g. myHotel, yourHotel, hotelCalifornia or hotelTransilvania are most certainly better choices for hotel object names.
In comparison, 'hotel' does not confer any meaning that you couldn't also get by hovering your mouse over the name and reading the tool tip showing the type...
Stefan_Lang
8-Jan-22 14:11pm
View
No idea who downvoted. I hate when they do that without giving a reason. Expect me to do so if I ever downvote you or anyone else ;-)
As for the topic being listed at the top, I guess that either someone posted something that was deleted afterwards, or something else caused it's date to be modified: the OP states it's just been updated, but the last update was in 2020 too...
Stefan_Lang
8-Jan-22 9:43am
View
This is a question from 2020
Stefan_Lang
8-Jan-22 9:36am
View
Please make sure that the code you post is actually and literally the same as the one you have problems with. If you want help, the least you can do is show us the problem as is, rather than a heap of garbage that no one can understand.
Stefan_Lang
6-Jan-22 6:55am
View
You are correct. I just remembered the '=' not working in some similar code, but apparently that wasn't the same as here. The line didn't compile and after removing the '=' and fixing something else it worked, so I thought that's how it must be.
Stefan_Lang
5-Jan-22 8:35am
View
std::cin reads from console input, and that means the user. That is the whole point of std::cin, so if you want to get input from somewhere else, you should use a different input device, e. g. a file (see std::fstream) or maybe an input data stream from an internet connection.
When you say, 'fill automatic', then what is doing the 'automatic' filling? What is the source? What or who decides how the filling is done?
We can only advise you on doing such a thing if you are more specific on what you have in mind.
Stefan_Lang
5-Jan-22 8:25am
View
You haven't mentioned what kind of problem you intend to solve, or why using modules prevents you from doing it with standard C++ techniques. Nor have you mentioned what functionality of Java initialization blocks you intend to recreate in C++.
I fail to see the need for this, or the problem you set out to solve: Constructors can - and should - do all of this for you, out of the box.
I expanded on that in my solution. It may not be the solution to your question, but it is most certainly a better way to approach this topic.
Stefan_Lang
22-Dec-21 7:40am
View
Have a 5. But if I were to write that code I'd add a paycheck*=100; somewhere ;-p
Stefan_Lang
13-Dec-21 3:52am
View
Very good article, must have missed that when it was published.
Stefan_Lang
7-Dec-21 12:30pm
View
Ok, admittedly I didn't use VS - godbolt is so much faster. Unfortunately it doesn't support the MS compilers, but I hope my explanation is still somewhat useful.
Stefan_Lang
7-Dec-21 12:15pm
View
I only now realized that you actually posted a solution in a comment yesterday. After checking the documentation at https://en.cppreference.com/w/cpp/language/alignas I can only agree.
Forget my comments on size_t vs int - that was really a shot in the dark based on some bad experience in an unrelated case.
Stefan_Lang
7-Dec-21 11:28am
View
I can offer precious little more info, only that with some versions of C++ compilers I've had difficulty when using specific numeric type as template arguments.
Typically the cause of the problem was a template instantiation with an integral literal that was then interpreted as an int, whereas the template used some other type, such as unsigned int, long, or char.
In such cases, the error messages were typically not very helpful. The fastest way to find out if it was related to the template specification, was change the integral type to int: if that resolved the problem, it meant I needed to find a wonky template instantiation that accidentally instantiates with the wrong integral type.
Stefan_Lang
7-Dec-21 9:46am
View
This seems a bit odd, but I remember compilers behaving oddly around any kind of template arguments other than types or int - unsigned int or size_t caused trouble or even compilation errors. Have you tried int a instead of size_t?
Stefan_Lang
7-Dec-21 9:42am
View
I totally understand. Personally I wouldn't do this myself unless I am really desperate to optimize my code, and have proven that this will fulfil the requirements (and then I'd make sure to document it very clearly!).
I only suggested this because some time ago I had to work with someones code who was crazy for premature optimizations, typically using inline, but also by extending templated code further than needed. (not saying your optimization is premature - that was just the context that made me think on templates being inline)
Stefan_Lang
7-Dec-21 8:25am
View
Thank you
Stefan_Lang
7-Dec-21 5:27am
View
The C++ compiler is very good at return optimization: if you construct an object at the start of a function and then return it at the end of the function, the compiler will not construct this object on the local stack of the function, but on the stack of the calling function - that way it doesn't need to be copied on return.
Stefan_Lang
7-Dec-21 5:22am
View
I'm inclined to agree: the std implementation and return optimization is so good nowadays that it's hard to come up with a syntax that works even better.
Moreover, when suggesting code to a beginner, there's no point wasting time on such subtleties: it's better to clearly write what you intend rather than a subtle alternative that solves a problem that no one asked about.
(and have a 5!)
Stefan_Lang
7-Dec-21 5:16am
View
In addition to what I have written in my solution, here is a very insightful article on the question of how to split a string in C++:
https://www.fluentcpp.com/2017/04/21/how-to-split-a-string-in-c/
While some of the things discussed there are probably beyond your current understanding, Jonathans blog is a very good source of modern C++ programming. It's always worth a visit if you want to learn more about C++ and modern programming techniques.
Stefan_Lang
7-Dec-21 4:48am
View
In the other threads he's opened...
(it's simply a #define alias for std::string - and yes I told him he shouldn't use #define)
Stefan_Lang
7-Dec-21 3:21am
View
Please do not tag your post as C++ when you're not talking about C++. Judging by your description, this can't be C++.
Also, when you ask for help, remember that we cannot see your monitor, and that we cannot read your mind. You have not told us what you want, only what you get. And you haven't shown us any code, so we have no basis to help you, beyond an abstract description of the steps you should take to help yourself (see solution 1)
Stefan_Lang
7-Dec-21 3:13am
View
The post is tagged as both C++ and Java, but the OP talks about assigning a null reference - this indicates it's Java, not C++
Stefan_Lang
6-Dec-21 13:14pm
View
If you have trouble understanding a specific concept ask or look it up e. g. on cppreference.com . You can find a lot of help and example code there.
As for statements like "this worked on another C++ program": that doesn't prove anything, except that, apparently, it's not the same program any more!
Stefan_Lang
3-Dec-21 15:11pm
View
I doubt this pseudo code will help someone who needs to ask for help on 1- and 2-dimensional arrays.
Your clever way of index conversion likewise is not a suitable answer to a beginner. Besides, you made a mistake there.
Stefan_Lang
30-Nov-21 7:57am
View
You don't seem to understand what a mutex is and what it is used for. Anyway, it doesn't prevent duplicate ids nor do anything else to help you.
As I posted in the other thread, and OriginalGriff stated: use GUIDs if you want unique IDs. No need to reinvent the wheel, especially when yours are squared.
Stefan_Lang
24-Nov-21 10:23am
View
"Core dumb issue" => Why isn't the core more intelligent? ;-p
Stefan_Lang
23-Nov-21 4:11am
View
I'm not very famililar with QT, but if you want to write text to a txt file, why do you use QFile? why not a normal file?
Stefan_Lang
22-Nov-21 12:09pm
View
The number 10 has digits 1 and 0, so the digits are decreasing.
The number 12 has digits 1 and 2, so the digits are strictly increasing.
12 fulfils the criterium, 10 doesn't.
Stefan_Lang
22-Nov-21 11:00am
View
The OP says "natural numbers that have a strictly increasing sequence of digits". So 1, 2, 3, and 12 would be in, but 10 and 11 would be out because their digits are not increasing.
Stefan_Lang
22-Nov-21 10:58am
View
Please don't post extensions to your original question as a solution, specifically if it isn't a solution.
Stefan_Lang
22-Nov-21 9:37am
View
I neither fully understand the question, nor this solution. Richards answer seemed to be entirely correct. That it neglects to mention you have a templated class doesn't matter in this case.
Your solution does a bad job in multiple aspects: it introduces unclear ownership of heap objects using unmanaged pointers, creates multiple redundant copies of user data, and creates proxy objects that may access invalid or outdated memory.
I'm not sure what purpose your proxy is supposed to fulfill, but as far as I can tell you're better off without it. Just implement the index operator for AdvArray.
Stefan_Lang
13-Nov-21 7:45am
View
If you only need this to initialize newly created objects the function should create the object, or, better, you should write a constructor that takes a Class2 object for initialization:
class Class1 {
int intVariable;
std::string stringVariable;
public:
Class1(const Class2& c2)
: intVariable(c2.intVariable), stringVariable(c2.stringVariable) {}
};
Stefan_Lang
24-Sep-21 10:05am
View
I did not ask for git command 'expansion', I asked for keyword expansion within source code on (initial) commit. Since we use different interfaces to Git, not just the command line, a change that only affects what happens on the command line wouldn't help.
Stefan_Lang
6-Sep-21 6:21am
View
This is not a site to provide solutions for free, it is a site to help people learn. If you have a _specific_ question about something you do not understand, ask, and we will explain.
But you have to understand that providing you with a complete solution does not give you an explanation. To the contrary, it robs you of an opportunity to learn. Asking for the solution means giving up to learn.
Stefan_Lang
11-Aug-21 8:28am
View
The difficulty is that the pattern is defined recursively. Sometimes it's 2 and sometimes 3 '3's in a row in between the '2's. The repetitions are defined by the previous iteration of the recursion. Unfortunately, while the iteration is hinted at, the initial value is missing. But I guess it's simply '2'. That would mean the second iteration generates 2332, and the third generates 233233323332332. (insert punctuation as needed)
Stefan_Lang
9-Aug-21 10:44am
View
I tried the settings according to the link you provided, but unfortunately the use of CLR does conflict with the debuggers' ability to display variable contents. Apparently it can't cope with a binary that sometimes does and sometimes doesn't use managed objects, at least in Release mode :-(
I am now considering to separate the CLR part from the rest, into a separate library, but it will take some tim eto implement...
Stefan_Lang
6-Aug-21 5:02am
View
See the "What have I tried" section. Didn't work.
Stefan_Lang
3-Aug-21 8:32am
View
As I already stated I've considered wrapping the API so that all objects passed into and out of it would first be translated into ones that are the same in debug and release builds. The wrapper would be separated into a release build DLL, but the rest of the DLL could then be Debug.
I think this should work, but it would be too much effort, both to develop and to maintain.
Stefan_Lang
3-Aug-21 8:24am
View
I'ts not a component, it is the main app, and our company develops plugins specifically for it. Switching to another is not an option.
Stefan_Lang
2-Aug-21 11:08am
View
You're right, of course, but unfortunately it doesn't seem the people I talk to on the vendors side are even half as reasonable. It doesn't help their codebase is > 30 years old, and the developers as well as the clients have learned to live with the system as is...
That said, confronting them with the argument that getting a debug version could help me finding bugs in their code might be a good idea.
Stefan_Lang
2-Aug-21 7:52am
View
Thanks, we're already using logging, but it's tedious and impractical, because the API functions take either a lot of arguments as input, or objects consisting of a lot of data, or both. Not to mention the API objects are _huge_, and it's incredibly hard to pinpoint which of the data members are actually important. And many can't be accessed directly, so the only chance to actually see the contents would be the debugger.
Stefan_Lang
2-Aug-21 7:48am
View
Thank you. I will try these. One question: just how much of a problem is that CLR setting (C/C++ > General > Common Language RunTime Support: No CLR Support)? I'm asking because we need to use CLR. I've already looked into splitting our DLLs into one encapsualting the CLR part and one pure native DLL. The former would be highly reusable, so it makes sense to do anyway.
Stefan_Lang
25-Jul-21 11:05am
View
No, I do mean declaration: extern Pub *gpub; is not a declaration! you will notice the difference when you try to build a program executable from an exe and a static library; if neither contains a declaration, then the linker will complain that it has an unresolved external symbol.
Stefan_Lang
25-Jul-21 9:48am
View
Err, no. See my solution. The library providing the extern declaration in its API is supposed to provide the actual declaration and - if needed - initialize the object. Or, in case of a function, provide the implementation.
Not doing so would break all expectations, and the linker would issue an error!
While it would be possible for the exe (or another library) to provide the actual declaration, how would it know how to correctly initialize it? This is part of the business logic of the library after all!
Stefan_Lang
25-Jul-21 4:35am
View
It's actually impossible to judge whether the use of extern makes sense in the given example without knowing how and where that header is used. If this is the header of a library, it makes perfect sense. See my solution.
Stefan_Lang
7-Jul-21 6:50am
View
Has to be combined peculiarity of the editor here, and whatever program that source came from. I've never managed to create such artifacts when pasting code here. But, yes, this happens way to often to be an accident.
That said, no matter what causes this, why are there so many people who don't bother to check whether their posting is even marginally readable?
Stefan_Lang
7-Jul-21 5:19am
View
If you could implement an operator for adding a scalar, then I don't get what is your problem? You should show the code you have for operator+({scalar type}), and the code you tried for operator+=({element type}). Then we have a chance to find and point out your problem.
Posting the code that you want to use that operator in doesn't tell us anything.
Stefan_Lang
2-Jul-21 11:19am
View
Why should anyone write this code for you? There are three possible reasons why someone wants code:
1. for homework
2. for work
3. out of personal interest
In case 1, the point is that you learn something by completing the task yourself. Giving you the code would deprive you of a chance to learn.
In case 2, you earn money from it. In this case, why should someone else do it for free?
In case 3, if you are not willing to do it yourself, why should anyone else?
Either way, it is unreasonable to expect or even ask other people to write a program for you.
Stefan_Lang
24-Jun-21 18:55pm
View
Lol, didn't notice. Well done :-D
Stefan_Lang
24-Jun-21 12:31pm
View
Almost perfect, except I'd rename the functions to getVolume() :-)
Have a 5 anyway
Stefan_Lang
18-Jun-21 3:39am
View
I don't know Python very well, but the code you posted looks like Python to me. Where is the C++ code you wish to convert?
Stefan_Lang
18-Jun-21 3:38am
View
Not only that, it looks like this actually *is* python: weak typing, lack of brackets, lack of ';', block defined by indentation (see last if block), implicit return type ...
I'm not sure whether Python allows the use of '-' within a name - but then I don't know *any* language that does.
Stefan_Lang
30-May-21 5:44am
View
On a sidenote: "bits/stdc++.h" is not a standard C++ header. If you happen to have a specific question rather than a full conversion request, you should mention the compiler you're using (GCC?)
Stefan_Lang
25-May-21 6:34am
View
Well, that is no new information. But the things I pointed out are not related to winhttp at all, but to the structure of your code in general: to arrive at the desired results, you need to perform a serious of function calls, and you can only expect your program to work as expected if _all_ of those calls succeed. Consequently, if any of your calls fail, you should stop.
The problem is that probably something failed before you call WinHttpQueryHeaders, and therefore this function cannot succeed! Check all result vvalues and print out an error message if any of these calls fail. Then you'll see what's going wrong.
Stefan_Lang
25-May-21 5:31am
View
When posting a question, please read and follow the simple rules you see at the right hand side. Most importantly:
- Choose a meaningful title
- Focus on a specific problem; don't ask for a full solution
- give concise information on what you tried, what worked, and what didn't work as expected
If you're not willing to follow these simple rules, others will be unlikely to aid you, because the overall impression you give is that you expect us to care about a problem you're too lazy to solve!
Stefan_Lang
25-May-21 5:06am
View
"Please what need to done to get response 404? "
First of all, format your code properly. A plain text dump is not something people are likely to read on their free time!
That said, it looks like you only have one long main function. That's the first problem right there: too much complexity within one function makes it a lot harder to understand what it's supposed to do, and what it really does.
Moreover, I see #include <iostream>, but no use of cin or cout, or any other feature of the C++ language - is your code supposed to be C++ or C? You might want to consider introducing classes for sessions, connections and requests and then use RAII to clean up dependencies and error handling: that would be the sensible thing to do, and it would help reducing complexity.
Stefan_Lang
25-May-21 4:09am
View
I'm not familiar with Node.js, but how can Napi::Float32Array::New() know about the size of the float array? Check the argument list expected by this function. I don't know anything about it, but I guess this function is used to create a container for an array of loat values, and that would require at the very least to pass the size of the required array, or alternatively pass an object that contains this info such as std::vector.
Stefan_Lang
27-Apr-21 3:25am
View
I see v3 of your question, and it looks like you accidentally replaced the text of your question with the input file. Please correct.
Stefan_Lang
27-Apr-21 3:15am
View
This question is many years old. Unless you have to add something really important, please do not answer such old postings.
More importantly, a code dump without explanations is not a solution! If you wish to provide any help at all, the most important thing is explain. Providing code is merely an afterthought to help illustrate your explanation.
Stefan_Lang
26-Apr-21 9:05am
View
I do appreciate that development, but I wish that at least the mainstream compilers would show consistent behaviour! It's not like list initialization turned up yesterday!
Stefan_Lang
26-Apr-21 8:42am
View
Thanks for the link. The first answer clears up much of my confusion: "List initialization does not allow narrowing".
This at least clarifies why list initialization behaves differently, and it may explain why in this case you get an error rather than just a warning.
It doesn't explain though why this depends on whether or not there is a special constructor in struct foo.
I've checked this code on godbolt, and I get very different behaviour depending on compiler and specific compiler version: some MSVC compiler versions give me 4 errors, some give me 6 errors (they don't accept the instantiations of foo e() and foo j()), whereas gcc at most gives me some warnings.
So maybe part of my confusion comes from MSVC being overly dramatic by turning those warnings into errors...
P.S.: just noticed that clang also issues errors rather than warnings, but unlike MSVC it doesn't change its mind depending on the presencee of the foo() constructor!
Stefan_Lang
27-Feb-21 11:08am
View
Yes, you are right. I shouldn't use FormulaLocal unless I can be sure the users are all using the same language installation of Excel. I wouldn't bet on that, given that I myself prefer to install english versions of any program whenever I can... (Office wasn't installed by me)
Unfortunately, I have solved my problem using FormulaLocal for one formula that uses IF(...) which for some reason didn't work in english, but did work with FormulaLocal in german. Thanks to your posting I realized I forgot to replace the function argument separators (';') with ',' for the IF statement - now it works in english! :-)
Thank you very much for posting this - it helped me find the right solution. Have a 5!
Stefan_Lang
26-Feb-21 11:42am
View
Thank you, that's a very useful link.
Stefan_Lang
26-Feb-21 11:39am
View
Hey, thanks - with PI() the formula works. I may check RADIANS() later.
*thumbsup*
Stefan_Lang
18-Jan-21 6:36am
View
What is your point in having a child process if it can't lead a separate life? Or to put it the other way round: if you want your child to die with the parent, why not create a thread instead? Threads are automatically killed with the master thread.
This is just a guess, but I like to think that the terms child and parent were chosen deliberately because children are normally allowed to outlive their parents. Whereas slaves depend on their master - and in some cases even in death. Therefore the use of 'master' and 'slave' for threads.
Stefan_Lang
17-Jan-21 14:25pm
View
As for debugging, I've developped embedded progams and was able to debug them right from my desktop PC. So I assume that something like that should be possible on a VM too. But I've never done that myself. Also that was 15 years ago, and I wasn't the one who set up the debugger. But I suspect that if it is possible at all, there should be useful info at Microsoft. Otherwise you should consider adding logging functionality to help you find out what your program is doing.
As for the rest, that's entirely outside my experience.
Stefan_Lang
17-Jan-21 12:59pm
View
I've never done anything like this, so I'm not posting a solution.
From a quick search, it looks like you have access to server system functionality, so that is something not many developers will have any experience with. The info I got for SeCreateTokenPrvilege only shows you have the right to create a token - not to create one with elevated rights.
This raises the question, why does it need elevated rights?
I suspect that you're calling functions that return with an error because the rights you have are not sufficient. Either that or there is simply an error in your code.
Either way, why don't you use a debugger to find out what is going wrong?
In any case, you should spend more effort into checking the results and errors of functions you call, specifically system functions that are not guranteed to always do what you want depending on various conditions.
Stefan_Lang
17-Jan-21 12:13pm
View
I'm not an expert on parsing, but I'd use a std::map<string_token,function_object> rather than implementing my own hash function and managing the results with a switch statement.
Or I just don't understand this topic enough and should leave this Q&A to the experts ;-)
Stefan_Lang
14-Jan-21 2:57am
View
Thanks for taking the time to investigate. Your results confirm what I suspected: that in case of doubt you better test what, exactly that rvalue ref does or doesn't do.
Stefan_Lang
11-Jan-21 8:04am
View
I know what rvalue references are. Well, mostly. I was just confused on what auto makes out of this. It doesn't help that in the actual code the container elements are supposed to be constant - I suspect that in this case it really doesn't make sense, but I wanted to be sure.
But I guess it won't hurt checking on "rr" again. Thanks for the links.
Stefan_Lang
11-Jan-21 7:34am
View
As for reading error messages: the problem is there is no error, not even a warning: it appears to be valid code. I just wasn't sure what it means and whether omitting one '&' would maintain or alter the semantics. And I couldn't find a good handle on what to search for.
Thanks for the link. It does mention the use of auto&& in range-based for:
"For example, given const auto& i = expr;, the type of i is exactly the type of the argument u in an imaginary template template<class u=""> void f(const U& u) if the function call f(expr) was compiled. Therefore, auto&& may be deduced either as an lvalue reference or rvalue reference according to the initializer, which is used in range-based for loop."
I'm still trying to wrap my head around that, but at least that's something to work with.
Stefan_Lang
11-Jan-21 5:30am
View
If that is the kind of code you get taught, then you really need a different teacher. Or just a teacher.
For starters, google on "Clean Code" principles. Here's a nice article that explains what "Clean Code" means and shows with a few examples how to write Clean Code.
https://simpleprogrammer.com/clean-code-principles-better-programmer/
Although the examples are not for C++, the principles are just the same. You can find a lot more articles and examples in the internet, and there are good books, video courses and other materials to purchase if you are really interested.
Note that the term 'Clean Code' is sometimes interpreted differently. E. g. some claim that in order to understand your code well, you need good comments in your code. I used to follow that standard as well, but over the years I've learned the hard way that the best code is code that someone else can read and understand without comments and documentation of any kind! That doesn't mean that comments are generally bad, or good. It means that in the end the most meaningful measurement of clean code is that others can read your code well.
And when I say 'others', that does include your future self in a couple of weeks or months: personally I've found that the person having to read my own code is me, most of the time - and I'm always happy when I find out that I did write my code well enough that I still understand it after months or even years!
Stefan_Lang
10-Jan-21 17:38pm
View
I wholeheartedly agree, especially to your edit. I haven't used goto in the past ~35 years, and although at times I was (grudgingly) talked into to leaving an occasional goto be (rather than eliminating it), I will no longer stand it. People should go look for articles and books on Clean Code rather than hack their way through an algorithm without thinking or planning.
(and have a 5 - sadly I can't give 6)
Stefan_Lang
3-Jan-21 12:34pm
View
When I was younger I used to write very long sentences, but I did use a lot of commas, hyphens, and semicolons. The grammar was fine, according to my teacher, but I never made it past one page. Anyway, when she made me read out loud those sentences I was cured! ;-p
Stefan_Lang
3-Jan-21 12:31pm
View
Indeed, I never thought of dereferencing a void*. When I think about it it's obvious you can't, but it's well worth mentioning in this context!
Stefan_Lang
3-Jan-21 12:26pm
View
A fair point. Just clarifying that there is a subtle but imortant difference between a void return value and a void* might have been all that's needed.
Stefan_Lang
3-Jan-21 12:24pm
View
Indeed - I thought I had mentioned that malloc doesn't know the required type, but apparently I forgot. My 5!
Stefan_Lang
3-Jan-21 12:15pm
View
Actually the sizes must only be sufficient for paragraphs per file, sentences per paragraph, words per sentence, and chars per word. but that still raises the question on how large these limits must be?
Stefan_Lang
3-Jan-21 11:40am
View
You use pointers either for large objects as described above, or in cases where you want to allow another function to modify a local variable, even if it's only a char or short value.
As for dynamic arrays, you cannot define one without a pointer, because without it you cannot access it's contents!
Stefan_Lang
3-Jan-21 11:32am
View
Mostly because C uses a function for this, and you can't define functions that only differ by return type. Moreover the C langauage can't possibly provide one function for each type, because the number of possible types is infinite.
The C++ new operator can work around that problem because it takes the result type as an argument. That makes each 'new' a different function that can have a different return type.
Stefan_Lang
1-Jan-21 12:21pm
View
Well spotted, have a 5.
Although I'd suggest a const int for the radix rather than a #define - after all this is C++, not C. (note: not unsigned int - a negative radix is actually a valid option ;-) )
Stefan_Lang
1-Jan-21 8:35am
View
Please do not post this kind of stuff:
- Posting a pointless answer to 5 year old question
- Not valid code in any language
- Not answering the question
- No explanation or comments
Unless and until you have something more useful to share, please keep it to your local computer.
Stefan_Lang
1-Jan-21 8:21am
View
I see. I haven't been on this site for some months so I'm not up to date to the who's who ;-)
And, yes, I also have some doubt as to the mechanics used in this program. There are way too many things I've spotted on a glance that seem dubious to say the least. That said, I always try to avoid this kind of low level Windows stuff, there's way too many traps for the unwary, side effects, odd (and type-unsafe) ways of passing information, unclear responsibilities, and generally outdated concepts (and when I say outdated, I mean concepts developed for Windows 3.x)
Anyway, have a happy new year!
Stefan_Lang
1-Jan-21 8:06am
View
Then we seem to have a different understanding - I wouldn't consider it wise to cast a pointer to an actual string into a DWORD and compare it to another DWORD that is clearly not a pointer and expect that to make any sense. Note that this pid is passed to FindWindow() which only expects string parameters.
Stefan_Lang
1-Jan-21 6:51am
View
What is 'dword' in your pid vector definition? If you mean DWORD, you must write DWORD. If the type dword is defined elsewhere, chances are that it doesn't match DWORD! This is all the more likely because the definition changes depending on whether you build for x86 or x64.
Stefan_Lang
1-Jan-21 6:20am
View
Thank you, and a happy new year!
Stefan_Lang
1-Jan-21 6:19am
View
Is it april 1st already?
Stefan_Lang
27-Dec-20 10:38am
View
Since each process manages it's own memory address space, the address alone doesn't tell you anything. What it refers to depends on the tool and function you used to find it! That said, a window isn't 'associated' to any specific address, It may be that a specific address at a specific time contains data that describes some aspect or attribute of a window, but that is likely subject to change.
The real question is: what is your intent? What do you want to achieve with the help of this information? If you can tell us that, we may be able to provide better advice.
Stefan_Lang
26-Dec-20 6:33am
View
Reported as repost. If there's anything you wish to add to your original question, you can edit it with the [Improve question] button at the bottom of your post. If you don't understand the solution, you can reply to the author with the [Have a question or comment] button at the bottom of that solution.
Stefan_Lang
26-Dec-20 6:23am
View
Not helping!
1. you're 3.5 years late to the question
2. There already is a solution
3. Your post doesn't answer the question.
4. Instead you posted C# code that is already mentioned in the question itself!
Stefan_Lang
24-Dec-20 5:51am
View
If the compiler you are using now issues the deprecated warning, that same compiler is saying that it should still work. Therefore, if your code doesn't compile with this particular compiler, the reason is most likely something else.
Stefan_Lang
24-Dec-20 5:48am
View
Great analysis on all counts. getItem() is spot on: the compiler tries to do a conversion, and this is the only location in the code that could cause this exact error message. I was also wondering about this function accessing the symbol Head: either this is a global variable, which is bad (but not fatal), or it is a data member of the list class, in which case this function is meant to be an implementation of a method, but is missing the class qualifier. (which would result in another compiler error)
Stefan_Lang
18-Dec-20 10:33am
View
Yes, I suppose I could have tried that. But they don't have a forum, just a mailing list, and I was a bit under pressure to find a solution.
Stefan_Lang
18-Dec-20 7:20am
View
As I found out the key is XERCES_BUILDING_LIBRARY, which is neither autonatically generated for the static library, nor explained anywhere in the web. As for the latter, I used Duckduckgo to search for it (to avoid all the search manipualtion by Google) and found exactly 7 links. In words: seven. One of them points here, one to a the header file that contains this symbol, 1 to a site that my browser won't open due to a trojan warning and two to sites with asian glyphs, which I opened anyway - but other than posting blocks of code containing the symbol they didn't seem to talk about this particular one. The other two likewise opened to sites with blocks of code, but didn't talk about this symbol.
Basically, the only way to learn about the meaning of this symbol other than reading my solution here is diving into the xercesc header files like I did.
Stefan_Lang
17-Dec-20 15:09pm
View
Apparently the #defines are automatically adjusted based on the build (in this case static lib). Also I misunderstoiod the linker warning, thinking that I need the xercesc stuff to be declared dllimport, when in truth the error is that they are in fact declared as dllimport, but shouldn't. That means the symbols with *EXPOT 1 are in fact correct - it's just that they don't lead to the desired results.
Stefan_Lang
17-Dec-20 14:13pm
View
Thanks, but I did build it as a static lib already. Unfortunately the site you linked does not mention anywhere how to link it to another binary statically. E. g. the symbol XERCES_STATIC_LIBRARY does not seem to be mentioned anywhere on that site - I got that tip from another place. It seems like that symbol is indeed queried, but apparently it isn't quite enough: the #define definitions I've found at least do not query it's state! Which leads me to believe that the logic was changed - and maybe in error.
Stefan_Lang
17-Dec-20 14:07pm
View
I actually have 3.2.3. The header is in the util subfolder. It does 'hardcode' some #defines (i. e. without checking for any settings, OS or whatnot), and I wonder if that's a bug. Maybe I'll check on previous versions...
P.S.: I just found a comment in the file XercesDefs.h, indicating that the header I mentioned is autoconfigured by the build that created the lib. Also, after double checking on the warning, it seems that the #defines in that file are correct - except that they don't work as intended.
Stefan_Lang
17-Dec-20 14:01pm
View
I specifically did build it as a static library, and there is indeed no .dll file. The .lib file is 93967 KB in size - that would be rather unusual for a DLL!
The problem is not with the binary, it is with the include files which insist on treating it as a DLL.
Stefan_Lang
25-Sep-20 6:24am
View
Actually, the argument type of isdigit is int. See https://www.cplusplus.com/reference/cctype/isdigit/
Your code will work because char gets auto-promoted to int. But declaring array_size as int is correct.
Stefan_Lang
25-Sep-20 6:05am
View
Agreed, I do the same. Except, when it's working, I leave it at the many simple steps. That way, when the next unfortunate guy gets to see that code he won't have to pick it apart again.
Stefan_Lang
17-Sep-20 5:25am
View
"and buttons were blue and white"
That explains a lot about C++ ;-)
That said, you fell for a necroed posting (from july). Not sure if your advice reaches the author (in time).
Stefan_Lang
16-Sep-20 6:07am
View
I know that, what I meant is that to use string - with or without std:: - you normally need to #include <string>. He didn't. This works on some compilers, if they do include string within the iostream header, but the C++ specification does not require this. Therefore including only iostream may not be enough, dependend on the compiler.
See here: https://stackoverflow.com/questions/16506095/do-i-have-to-use-include-string-beside-iostream
Stefan_Lang
16-Sep-20 6:03am
View
While a coma is a sure source of errors, I suspect you actually meant "comma" ;-p
Stefan_Lang
16-Sep-20 5:48am
View
I can confirm this, although I would have expected that the code needs an #include <string>. Maybe that is the problem: while some implementations may include <string> within iostream, others might not.
Stefan_Lang
2-Sep-20 11:47am
View
Thanks.
Stefan_Lang
2-Sep-20 11:46am
View
Thanks a lot.
Stefan_Lang
2-Sep-20 11:46am
View
Thank you
Stefan_Lang
2-Sep-20 3:27am
View
I once worked on a GA solving uch a scheduling problem. The example given had several hundred jobs and 4 machines - impossible to solve using brute force, and most certainly not in the 90s! But the GA could find a near optimal solution within 20 minutes, where a human expert (who formerly made that schedule) needed the better part of a week to arrive at a solution of similar quality.
Stefan_Lang
1-Sep-20 12:07pm
View
While I did suggest storing divisors (and reuse them for multiples of that number), it's far from obvious how to find the additional divisors without accidentally including duplicates. In fact, I'm not sure it would help a lot - but that would require some testing.
IMHO that test is deliberately using a compiler with optimization turned off, to measure the ability of the programmer to find minor optimizations such as avoiding duplicate calculations.
Stefan_Lang
25-Aug-20 11:57am
View
I have no idea about Antlr or how it works. But the grammer you defined doesn't distinguish between a for loop body consisting of a single statement ending in ';', or a code block enclosed in '{' and '}' which may not end in ';'. Specifically your last code example has multiple for loops not ending in ';'
Stefan_Lang
21-Aug-20 3:44am
View
I wonder, where did you get that task from? I am asking because of this requirement:
"and the plane coordinate system class is the parent class of the other two class."
This is very bad for the program design, and breaks core principles of object oriented programming! If this is an online course, find another: this is not the right place to learn C++! If this is not online, then maybe there are other students you could ask for help. But, if possible, you should still try to find another course - this one is likely a waste of time.
P.S.: if you find another, better course for object oriented programming, maybe tell your tutor to join you: he clearly needs it! ;-)
Stefan_Lang
17-Aug-20 11:33am
View
Have a 5.
You might also mention that calling main() at the end of the loop is a recursion! Didn't he say he was supposed not to use recursion? ;-p
Stefan_Lang
17-Aug-20 4:44am
View
Looks fine to me, but if you point out 'meaningful names', maybe you should go all the way and write out the names rather than choosing abbreviations, e. g. column_index rather than ColIx. While your version can be grasped well enough, mine takes considerably less effort to read and understand.
And writing long names is not an issues in the age of modern autocompletion functions! ;-)
As for your fear of mixing up rows and columns, the best way is to use a matrix library such as Eigen, or else to implement a matrix class yourself with functions to explicitely select a specific row or column - then it's pretty much impossible to mess it up, and you don't need to remember how the data is stored every single time.
Stefan_Lang
17-Aug-20 4:12am
View
I fully expect it to be a typo, because otherwise the compiler should complain. But I've seen too many cases of inane macro definitions to exclude a typo-induced bug that the compiler wouldn't notice.
Besides, if there's one obvious typo in the code that makes it uncompilable, who's to say there aren't less obvious ones that don't? :o)
Stefan_Lang
14-Aug-20 3:34am
View
I've never used these commands myself, but whenever I set a path with any function, I usually add a final '/'. Just a shot in the dark...
P.S.: didn't you forget a leading 't' in that call to tls_config_set_ca_path(), or is that a typo in your code?
Stefan_Lang
12-Aug-20 5:29am
View
I agree with Rick York (solution 1) that you should have a default value. Mathematically, an interval is the set of all numbers from a given base set (integers, real numbers, etc) that fulfill the condition to be within the given bounds. An empty set *is* a valid set, and a valid interval. Therefore your class should be able to represent an empty interval.
One other thing: don't declare overrides for comparison operators (<, <=, > and >=) unless the set of all intervals is a fully ordered set with that definition. Your definition does not fulfil this condition, as you can have two intervals that are neither less, not greater, nor equal! It's dangerous to define operator<, because it implies a strict ordering, and allows such things as calling std::sort. However, calling sort may give you different results for the same set of intervals if you pass these intervals in a different order!
If you have use for some kind of less/greater than comparison, use a normal function or method, not an operator override.
P.S.: if you want a valid operator<, it should be defined in such a way that it fulfills the following conditions:
a<b && b<c ==> a<c
a>b <==> b<a
a==b <==> !a<b &&!b<a
a==b && b==c <==> a==c
It's the third condition that your implementation breaks.
Stefan_Lang
12-Aug-20 5:19am
View
"who learns assembler language before C?"
I did. Order of languages at university during the first 1.5 years was: Pascal, Assembler, Lisp. I learned Fortran and C later when I actually needed it for projects.
My first computer was a C=Plus4, which I got after learning Pascal. Therefore, unlike many of my colleagues, I actually learned structured programming before being spoiled by Basic. Which explains a lot about my deep loathing of goto. ;-)
As a matter of fact, I never properly learned C - the first real 'C' project was actually C++, although we didn't have C++ compilers at the time: instead we used a precompiler that turned C++ code into some kind of mangled C. Well - more of an alpha version of a precompiler: it changed every couple of weeks!
Stefan_Lang
11-Aug-20 3:26am
View
Like you said: the OP made no effort. It's hard to be anything but vague when the actual question is already unclear!
Yes, it's ok to make a few assumptions above and beyond the actual question, but there's a high probability that some or all of these assumptions are wrong, and therefore the resulting response not as helpful as it may seem to a superficial reader (other than the OP).
While solution 2 is rather concrete and helpful, it's entirely unclear whether it's actually helpful to the OP, since it mostly answers questions that haven't been asked!
P.S.: maybe this should have been posted as a comment rather than a solution.
Stefan_Lang
10-Aug-20 7:27am
View
Agreed. The interval needs a 'default' value simply because the input vector may be empty! In that case the result cannot be any regular interval!
[edit]removed the last part as it doesn't apply to integer intervals[/edit]
Stefan_Lang
10-Aug-20 6:29am
View
The people in the QA forum are more than willing to help anyone who is in need of help. But they cannot see what is in your task description, on your screen, or in your head. You can make their task a lot easier by describing your task, the things you have tried so far, and the exact problem that you have right now. The less information you are offering, the more work it will be for anyone else to find out what you actually need.
Stefan_Lang
24-Jul-20 8:56am
View
Just another tip if you go back to VS 2010: do yourself a favor and turn off Intellisense! It's a performance (and memory?) hog, and doesn't work very well anyway (at least for VS 2010). There are a few free plugins with similar functionality that may still work with VS 2010. Me, I prefer VisualAssist, but it's not free - you might want to have a look at the free 30 day trial though.
Stefan_Lang
24-Jul-20 4:22am
View
He specifically asked about non-alphanumerical characters such as '['. x20 won't help there.
Stefan_Lang
14-Jul-20 5:18am
View
I agree, but I doubt this advice will help a lot without an explanation *why* this is saner.
(also, but that's just an IMHO, it would be even clearer if you declare that function argument const - that would make it impossible to abuse it as a local variable)
Stefan_Lang
14-Jul-20 5:04am
View
Actually it's 'please'. Shouting would be inappropriate ;-)
Stefan_Lang
14-Jul-20 4:52am
View
And so did I - didn't expect to learn something so basic after decades of programming in C++!
Have a 5.
Stefan_Lang
14-Jul-20 4:47am
View
Normally, just posting the state of the code at one point and the very first error message you get for that specific code should be enough for us to get a hunch what is going wrong.
However, if you messed with your project settings it's getting a lot harder for us to figure out what's happening. Therefore, to save you and all of us a lot of headaches, please go by my advice, throw your project files away, and create a new project with correct settings. Visual Studio will create most of the files and code that you need, and if something doesn't work, we'll have a much better chance to help you.
Stefan_Lang
14-Jul-20 4:42am
View
If this is really your first assignment, I doubt your tutor wanted you to write a recursive solution - especially since you would normally need an 'if' just to check for the initialization of the recursion (input without any octals in it). Which reminded me that my pseudo code was missing just that check, so I updated my solution to include it, and used the '?' ternary operator to avoid the need for an 'if'.
However, I suspect your tutor wanted to see something different, and your best bet is to check the notes from your lecture(s): it should feature whatever technique your tutor had in mind.
The only 'first assignment level' solution I can think of, is unroll the loop into a sequence of steps.
Stefan_Lang
18-May-20 7:28am
View
Maybe you should mention WexFlow in your topic title. That would greatly increase the chance to draw attention of someone who actually knows that product.
Stefan_Lang
27-Apr-20 6:22am
View
There is no guranteed way to achieve this without changing the actual source code of the program.
There at least two obstaces to your idea:
1. While Microsoft specifies how resources such as strings are supposed to be handled, there are lower level methods to achieve the same, and programs could use any of those other methods. The program could even store and redraw everything as an image, rather than storing it as a string!
2. The memory that a program uses has very restricted access from other programs. That is a matter of security: if any program could simply modify the memory of another program, it could do all kinds of malicious stuff!
3. While memory addresses used to correspond to phyical addresses 30 years ago, nowadays only the memory manager knows the true physical address. Therefore, even if you find a physical address that you can modify to change a currently running program in any way, it will not work the next time you start that program, because then all addresses will be different! These kind of techniques may work on some embedded systems which do not use virtual memory addresses, but not on modern operating systems.
Stefan_Lang
3-Apr-20 3:58am
View
Ah, I misunderstood - I thought you meant your system being the 'client side'. But you meant an actual client who installed a server :D
In that case I have no idea. AFAIK it's not possible to migrate the history from GIT *in general* since it's a distributed system and is capable of recording changes that SVN doesn't know how to store.
If you say the local SVN server is not available *now*, would it be an option to just tell the client to wait until *later*? At least for the history?
Stefan_Lang
3-Apr-20 3:27am
View
Do you realize that a GIT client has all the functionality of a local SVN server? (except for the sharing with others, obviously)
Stefan_Lang
1-Apr-20 2:43am
View
Actually, I always use .0 too, even when it's not needed. The reason is that sometimes the compiler might interpret the code differently based on the type of, e. g., a function parameter. Then it's important to specify the right type.
It also helps you detect inaccurate types: if you accidentally declare a variable as int (or similar), the compiler will point it out once you try to initialize or modify it with a .0 literal.
Stefan_Lang
31-Mar-20 10:57am
View
Ahh, the mighty VARIANT ... it's been ages I last had to use these, and I'm happy these days are past.
You have my condolences.
Stefan_Lang
31-Mar-20 5:46am
View
Thanks. I had 5ed you as well - why would I refer to your solution otherwise ;-)
Stefan_Lang
26-Mar-20 3:52am
View
Please don't abuse other people's QA for posting random code! It's just wasting everyone's time! And it will get you reported for spam.
Stefan_Lang
26-Mar-20 3:48am
View
That's actually very good advice: maybe it will give people an idea just how pointless it is nowadays to provide the assembler code by yourself ;-)
Stefan_Lang
25-Mar-20 12:13pm
View
I hadn't expected it's printf - have a 5!
Stefan_Lang
25-Mar-20 12:00pm
View
P.S.: I've found some documentation here: http://www.codeblocks.org/user-manual
Unfortunately no word on floating point representation.
Stefan_Lang
25-Mar-20 11:50am
View
It should come with the compiler: if it offers a graphical user interface, you can probably access it with the F1 key, or via Help menu.
It might also be public, but a quick search on "Codeblocks floating point format" turned up empty. :-( Maybe different keywords would help.
Stefan_Lang
25-Mar-20 9:51am
View
You are correct, I was wondering about that and looked it up. Fixed my statement, although, since most compilers nowadays use IEEE, it might not be *the* answer the OP was looking for.
Stefan_Lang
16-Mar-20 5:58am
View
...the compiler don't just say 'you have an error ! na nana na ..."
Now I wonder if there *is* a compiler like that - it would have some entertaining value ;-)
Stefan_Lang
13-Mar-20 10:45am
View
I'm pretty sure they're capable of such mistakes all by themselves :o)
Stefan_Lang
13-Mar-20 8:35am
View
This may be a problem of language, but when you say 'item 9' I understand 'the element arr[8]'. There is no such thing as 'item 0' in my understanding: the first element in a set is always item 1.
I'm not sure whether a native english speaker would understand it differently.
Stefan_Lang
12-Mar-20 10:54am
View
You probably mean sprintf. fprintf prints to a file, not a buffer.
Stefan_Lang
11-Mar-20 5:08am
View
"What I have tried:
mine
end"
Really? If that is all, then maybe you should find a language tutorial instead of picking up random tasks.
Stefan_Lang
9-Mar-20 11:03am
View
The insert statement uses '$roll_no' and '$period1' as values. But you don't seem to have specified variables by these names, only '$roll' and '$period'.
Stefan_Lang
9-Mar-20 10:50am
View
I suggest a simple test: exchange the sql statement assignments with very simple one-line queries (e. g. "Select State from NCS_DA_Other_Survey_Candidate_beneficiaries_NCSC_DAs". Then run your program and see if it runs without stack overflow.
If it does, then solution 4 is correct: the string concatenation causes the overflow due to too many additions.
Otherwise it's something else.
Stefan_Lang
9-Mar-20 10:41am
View
I think that could actually be true: every '+' translates into a function call, so an expression with 50 additions results in a 50 times nested function! Since every nesting level adds to the use of stack memory, that could cause an overflow.
Stefan_Lang
9-Mar-20 9:06am
View
Copying a wall of code is lazy. If you, who knows the code best, can't be bothered to spend a very moderate amount of time to pin down the relevant lines that are causing this issue, then don't expect that anyone else is going to spend a considerably larger amount of time to dig through your code in search for a rather vaguely specified problem!
Stefan_Lang
9-Mar-20 8:54am
View
Good advice. However, I'm not an SQL pro, and now I ask myself: what is the recommended alternative for putting together a query?
P.S.: never mind, I found the answer following the fourth link you provided
On a sidenote: the 5th link doesn't seem to work
Stefan_Lang
9-Mar-20 8:47am
View
I may be missing the obvious since I have no idea what you're trying to accomplish, and I have no knowledge of JSon either.
But I have to ask: Why do you place code to get a response from the server on the server??
Stefan_Lang
9-Mar-20 4:16am
View
"There is a network of tracks (list), tracks are of two types - standard (with one start and one end point) and with a fork ( one start and two end points)."
and
"The graph is not a tree, it has many edges and loops"
If your graph has loops, does it matter what is an end point or start point? Do your tracks have a direction? Can a node be the 'end point' of two tracks at the same time? Can a node be start point to two different tracks?
Stefan_Lang
9-Mar-20 4:04am
View
"Write a method that determines whether it is possible to delete a specific track, provided that the network should not break."
What is a network? (in this context) I have to ask this because according to your previous information there is no sensible interpretation of that term beyond 'set' - which doesn't really help.
Define "break". What does it mean when a network is *not* broken.
Stefan_Lang
9-Mar-20 3:53am
View
It isn't possible to implement that, because the requirements are contradictory! Please make sure you provide the correct definitions and requirements.
I think your definition of 'track' isn't right, or maybe you have an odd interpretation of what 'connected' means.
According to your definition, a track could be visualized like this:
O
|
|
O
or
O
|\
| \
O O
The Os represent the nodes. Is that what you mean? I have to ask because 'track' has no special meaning in graph theory, and I have no idea what your application's understanding of this term is.
"Each track can only be connected to one other track" means that you can only have singular tracks, or a pair of tracks: you can't connect a third, because in a connected pair, each track is already connected to one other track." Note that 'connected' is a symmetric relationship and affects both operands, not just one! If you meant something differnt, you need to use a different term that expresses this, or specify what you mean by 'connected', or just adjust the restriction to appropriately.
Stefan_Lang
9-Mar-20 3:37am
View
I have removed those spurios ="" tokens from your code, and fixed the formatting.
Note that after fixing the formatting, the missing brace issue in the second for loop that Richard pointed out really stands out! Therefore: always make sure to properly indent your code.
Stefan_Lang
6-Mar-20 11:44am
View
It's not the namespace you need to declare, but the symbol fs, which is an alias to the namespace declared in <experimental filesystem="">. That's why Richards solution originally didn't work: the compiler did recognize std::experimental::filesystem at that point, but it didn't know what the symbol fs meant.
Stefan_Lang
6-Mar-20 11:41am
View
Well, yes, you should *avoid* including headers in a header file if you can. But here there is no other reasonable way. That's why I added that last paragraph.
Stefan_Lang
6-Mar-20 10:29am
View
Solution 1 offers great advice, but there's one more thing you can try (if you haven't already): run the release build of your program on your own machine.
If it runs fine, then the only idea I have is that your program refers to a file or other resource that is available on your machine, but not on other machines,
If it doesn't run, then there is a difference between release and debug - then you can look for code that only runs in Debug mode, such as assert statements.
Stefan_Lang
6-Mar-20 10:14am
View
Almost: it's still missing the declaration of the symbol fs.
Stefan_Lang
6-Mar-20 9:29am
View
I think I misinterpreted your code: it's not that it keeps creating too many threads, but it does create too many sockets, and then never closes them.
Compare to the example coded posted here: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-accept
You can see there that the socket does gets closed even if it's invalid. You don't do that in your code.
Furthermore, you create each socket twice: first within the while condition, and then immediately afterwards within the while block. It overwrites the first socket, without properly releasing it.
So far I don't see why that would create notable CPU load, but I suppose it can't hurt fixing that and see if it helps.
Stefan_Lang
6-Mar-20 4:38am
View
I don't think that's generally possible. Not without cooperation from those web sites or the servers that are hosting them.
That said, many sites do publish their counters prominently on their site. So you might be able to retrieve that information from these particular sites. I have no idea how to approach that however.
Stefan_Lang
6-Mar-20 4:00am
View
Have you tried googling for Web Counters? This is one of the hits I got:
http://code.activestate.com/recipes/310320-webcounter/
Stefan_Lang
6-Mar-20 3:18am
View
The code you posted does not stop at 7, it keeps creating new threads.
Stefan_Lang
6-Mar-20 3:17am
View
I didn't say post code, I meant that your code doesn't appear to know about your hand-held devices, and the number available! You should put that kind of information in your code, so it doesn't needlessly create new threads.
Stefan_Lang
5-Mar-20 11:06am
View
Fine, then tell it to your code.
Stefan_Lang
4-Mar-20 10:57am
View
onlinegdb accepts it just fine: https://www.onlinegdb.com/online_c++_compiler
Stefan_Lang
4-Mar-20 10:56am
View
I've added this line to SomeFunction() in onlinegdb compiler (https://www.onlinegdb.com/online_c++_compiler):
cout << arr[0] << endl << arr[1] << endl;
This outputs
Hello
World
So what is your question?
Stefan_Lang
4-Mar-20 10:10am
View
No problem.
It's not that this is a bad question, just that these kind of questions require much more time and explanations from your side. If your code doesn't already work for the most part, then there's no point posting any - to the contrary, it will just distract from the actual problem.
Most of the time in such cases it takes a lot less time to google for the answer you're seeking, because you have the knowledge needed to decide which answers are useful - whereas we have no idea if the suggestion we have in mind is of any help to you, unless you spend a lot of time explaning what you need, exactly.
Stefan_Lang
4-Mar-20 2:35am
View
Well, you *did* say that 'maybe I'm missing something' ;-p
Creating threads unconditionally in a loop can never be a good thing - you don't need to know anything about sockets or servers for that.
*I* don't know anything about that, but I don't think there should be unlimited sockets, nor should any of them be created without a reason (i. e. some kind if client using that socket). I'd expect something like a master thread that receives requests for new connections, and then creates one. Whether in a new thread or not I don't know or care.
Stefan_Lang
3-Mar-20 5:06am
View
Very reasonable suggestion. Have a 5.
Stefan_Lang
3-Mar-20 5:05am
View
Where's the point of downloading the uploaded file for comparison just to prevent an unnecessary uploading? You're not reducing network traffic in this manner - on the contrary, you'd increase it!
The solution makes a very reasonable suggestion: rather than comparing the entire files, store a hash with each file, and only compare the hashes. That way you only have to download the hash of the uploaded file for testing. Is that not what you want?
Stefan_Lang
3-Mar-20 5:00am
View
Several issues:
1. Please do not post your own comments or further questions as a solution! Unless it is a verified solution that you have successfully validated to work exactly as you intended! Your code is pretty obviously not a complete solution, so do not post it as such.
2. Add any new insights and questions to your original posting! That is what the green [Improve question] button at the bottom right of your question is for! (Hint: it's only visible when you hover your mouse pointer over your question)
3. Please do spent a little effort on formatting your postings in a meaningful way! You have just used a standard formatting tag on your entire posting including code and normal text. That doesn't help anyone.
3.a) Do separate text and code and other elements, and then format them separately with the most appropriate options. Text should normally not use any formatting tag at all; code should use the appropriate code+language tag.
3.b) You don't have to write these formatting tags by hand; instead you can just select the block you want to format, and use the formatting tags on top of the edit box.
3.c) You can even preview the results before posting - do use that feature and don't post if it doesn't look like you expected!
3.d) Indent your code. before posting, or make sure that already indented code doesn't lose it. Nobody wants to read a wall of text and figure out what is what!
4. Your file read loops may not work as expected, due to two issues:
4.a) getline() returns an istream object, not a bool. Using it as a condition doesn't make any sense. You have to call an appropriate function to check the state of the istream object instead, e. g. good().
See http://www.cplusplus.com/reference/istream/istream/
4.b) why do you break out of the loop after encountering an empty line?
Can't there be more text after an empty line?? See 4.a) about properly checking for the end of the file!
4.c) I haven't checked in detail, but it seems your code performs a full text comparison. To do that, you need to effectively copy the remote file. Doesn't that make the whole process obsolete? Wasn't your point to avoid copying the entire file over the network unless necessary? Why then are you doing just that right at the start of your program?
Stefan_Lang
2-Mar-20 10:15am
View
I'm not very familiar with Regex, but I think you are supposed to concatenate all lines and let the Regex extract the resulting the addresses from the multiline string. No loop required.
Stefan_Lang
2-Mar-20 7:59am
View
This looks like C#, not C++. Please set the correct tags on your question.
Also you mixed code, Your explanatory text, and some HTML source into the code formatting. Please separate these and use the appropriate formatting for each.
Finally, when you post so much code, you should put in some effort to point out where in the code it is not working as expected. That is very little work for you, but takes a lot of effort for anyone trying to help.
Stefan_Lang
2-Mar-20 7:49am
View
"function add_trusted_application(string appPath)"
It is always the OS that will decide what is a trusted application, and which applications should be granted what access to any particular files! If the OS doesn't have the exclusive right on that, that opens the gates to all kinds of malicious software: Who would want an OS that allows a program to hide the folder that holds the malicious code which infects evrything?
Stefan_Lang
2-Mar-20 7:20am
View
That is the kind of info you should have added to your question with the [Improve question] button at the lower right of your question.
This time I did it for you, and restored some formatting to make it readable too.
That said, this code is incomplete, and not very helpful to understand what your problem is. If you're stuck, you should put a little more effort into explaining where.
Stefan_Lang
28-Feb-20 3:05am
View
I've thought of that, but am still convinced it makes no sense to model it this way. The administrative relation is only to your department manager, not to your project managers. If you want to model the relations regarding projects in your DB, then you need to set up a project table with a 1:1 relation for the project manager, and 1:N relation for the team members.
Stefan_Lang
28-Feb-20 2:54am
View
Good try, but I think Originalgriff (solution 2) nailed it: the relations are wrong.
Stefan_Lang
28-Feb-20 2:52am
View
Apart from my difficulty in understanding what assigned/taken/cashed* is supposed to mean, I think your suggestion makes a lot more sense.
*: when I think about it, the corresponding german terms used in our administration are also not very intuitive ;-p
P.S.: have a 5
Stefan_Lang
27-Feb-20 8:09am
View
Actually the compiler will accept that if statement and produce a completely useless result at runtime.
Stefan_Lang
21-Feb-20 7:15am
View
Sorry, but you didn't say before or otherwise indicate that you're a beginner.
I *told* you how to implement it, but if you do not understand how to use it in your program, then this program is way over your head. I could literally type out the program for you, but why should I spend time on that, and what would be the purpose? It does not do anything meaningful, and you cannot learn to program if others write the program for you.
When i learned programming, the internet didn't exist. I went to the library or bought real books to learn. For you it's much easier: plenty of tutorials and great articles for beginners are right there on the web, just one search away. I'm not going to spend hours teaching you step by step when there's so much material available for free.
Stefan_Lang
21-Feb-20 4:54am
View
You could add code to test pointer values not for null, but for numbers below 1024. This is not 100% reliable, but when you have issues with memory allocation, the invalid pointers will be in that range most of the time. In any case, no valid pointer should be in that range, so you won't catch false positives.
P.s.: I've read that in some thread on SO some time ago. Unfortunately I can't find the link anymore, so I can't say what the source is for 1024. However, in UNIX, and probably some (most? all?) Linux distributions, addresses below 0x8000 are treated as seg fault. I have not found any such limit for Windows 10, but Win32 (without the /3gb switch set) used to reserve the address space below 0x10000.
Stefan_Lang
20-Feb-20 7:14am
View
'not working' is not sufficient information. Also I don't see that you even used my suggestion to fix your problem. Why do you expect it's suddenly 'working' now?
Stefan_Lang
19-Feb-20 7:31am
View
Ah, of course. I somehow always implied function scope without saying it. Modifed my comment to clarify that.
Of course, as you say, you can reuse names in different scopes within a function, but you have to be careful. My advice was on the 'better be safe than sorry' line, not a literal prohibition.
Stefan_Lang
19-Feb-20 5:06am
View
I skipped them deliberately: Even though you can reuse names temporarily within a limited scope, doing so is just asking for trouble. If there is an actually resonable use case for that, I haven't heard of it.
Stefan_Lang
19-Feb-20 3:01am
View
Very good link. If that doesn't help, I don't know what will.
Show More