15,867,985 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 Visual Basic questions
View Python 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 nv3 (Top 200 by date)
nv3
19-Nov-21 16:12pm
View
Very welcome!
nv3
1-Feb-19 3:53am
View
Fine advice to a newby! That's how to do it.
nv3
17-Dec-18 3:51am
View
And replace that "1st" by "lst" -- in C++ identifiers don't start with a digit! It almost looks the same, but makes a great difference. That's what happens when one just copies things and doesn't try to understand what's going on.
nv3
1-Oct-18 17:01pm
View
How many digits of precision do you expect when computing in type double?
nv3
22-Aug-18 17:35pm
View
I am reading this entire thread and wondering what's the big deal of solving the problem in one line. It just depends on how long that line may be. With very few exception, C code is not dependent on any line structure. So every C program can be basically be written in one single line. Not that this would make any sense to a human reader :-)
I am glad the teacher solved the misunderstanding. Otherwise I would not have seen what good it would do to a class of beginners, actually any C or C++ class.
nv3
7-Jul-18 17:33pm
View
This whole scenario is as unrealistic as it can get. In real life, all that would take place in a database, not in in-memory data structures. Hence, the example is a bad one. And a couple of other things are unrealistic as well: You would not remove an item from your inventory until an order has been placed. And of course, you would not organize access to your items in a linear list. This is probably all not your fault, but a somehow misguided course is leading you in this direction. There are better examples for questions regarding data structures and their efficiency.
nv3
20-Jun-18 17:40pm
View
Displaying the content of an XML file in combo box? Why a combo box? Doesn't make much sense to me. A text box or rich text edit box would probably be a lot more suitable.
nv3
14-Jun-18 2:42am
View
Any textbook on C++ would have told you :-) But solution 1 will get you there also.
nv3
28-May-18 6:07am
View
Got it. Sorry.
nv3
28-May-18 5:44am
View
I doubt that will work if you leave the i++ out of the loop :-)
nv3
24-May-18 12:43pm
View
What you have tried looks good so far. Just continue! :-)
nv3
25-Mar-18 11:14am
View
Sorry, we don't do homework here.
nv3
25-Mar-18 7:37am
View
What do you mean by "java or C++"? Is it the one or the other? And besides, if you can't solve a problem like this by yourself, you probably don't deserve that 10% raise in salary :-)
nv3
9-Mar-18 3:35am
View
That's why it might be a exactly a good language for beginners :-) I know a lot of excellent developers who have started with C, so it can't be that bad after all.
nv3
20-Feb-18 15:33pm
View
Therefore I wrote "generally" :-)
nv3
1-Feb-18 8:55am
View
Apparently you are determining the max and min speed by feeding in a bunch of values and doing a polygon interpolation. That however just gives you an approximation and the real maximum speed can be higher. You should re-think your algorithm and what you really want to achieve with it.
nv3
31-Jan-18 11:44am
View
I don't think that "vertex" is good name for V, as it refers to the maximum number of vertices supported by that object. "maxVertices" would probably give a better representation.
But that is not the only bad practice in the code. "adjList" should be "adjLists" as it is a collection of lists. And I would actually recommend to use an array instead of a list in this context.
nv3
30-Jan-18 17:15pm
View
The array color is an array with the same number of elements as the Graph has nodes. Think of each node as having a node number of 0 to V-1. Line
int v=*it;
extracts a node number of one of the adjacency lists. We can than check the color of this node by color[v]. Think of color as an additional property of every graph node. As it is only used in the isCyclic function it is only allocated there and kept as a parallel array.
Note also the bugs in this code: color is never freed! And neither are the adjacency lists!
nv3
5-Jan-18 1:16am
View
You will be facing the problem that the name on the screen usually is only the last part of the complete path name, for example only the filename. And without the full path name you won't be able to uniquely identify the file in the Win32 API.
nv3
22-Nov-17 12:34pm
View
Fully agree with what you recommended. Just want to add two thoughts:
a) Consider to do the whole project in C++ (or C#) and save yourself to complexities of interfacing two worlds.
b) If this is your first project you are probably going to need some help. If this is a large project (as you said) then this is going to be a significant task and not necessarily suited for a beginner.
Good luck!
nv3
16-Nov-17 18:34pm
View
You left out the most interesting part of code: The computation whether the given year is a leap year. That is what this exercise is all about. Don't expect anyone here to do your homework.
And by the way, you should make a decision whether to post your question under C++, Java, or Javascript. Certainly not all of them.
nv3
3-Nov-17 2:16am
View
Well, if the debugger blames the statement "if (x < node->data)" then look at the value of node. My guess is that it is 0 or undefined, which in produces the segmentation fault. The next step is to find out, why node has the wrong value in that particular test situation. That's how debugging works.
nv3
25-Oct-17 1:59am
View
Start by looking at the patterns. What do you see? In the first line there is one group of 10 stars, then a space and another group of 10 stars, then a space and a single star. Now look at the next line. The first two groups have shrunk by one star each, the third group has grown by one star. And in the following line that rule is continued.
So your program should contain a big loop for the line doing 10 rounds. Inside that loop you need three mode loops, the first two of which start out with 10 rounds and the third one starting with one round. Then every iteration of the outer loop the loop counts of the inner loops must be adjusted accordingly.
Got it?
nv3
10-Oct-17 5:54am
View
What makes you think that type char for emp_name could hold an entire character string? It holds just a single character. Open your C++ text book and start reading the first 10 pages. Then try again.
nv3
15-Apr-17 4:18am
View
Didn't you mean pw.Intersect instead of pw.Union? Except for that I fully support your point.
nv3
11-Apr-17 3:46am
View
You forgot to also change the calling site and the code inside the function. The idea of passing the entire structure is that the function can do the loop over n inside and process the entire array in one call.
nv3
10-Apr-17 17:52pm
View
Try
void simp (struct array* pArray, double x1, double x2);
and call it by
simp (&array1, data1.x1, data2.x2);
By the way, I don't understand what you are trying to accomplish with those unions. Just use simple double variables.
nv3
7-Apr-17 14:46pm
View
How true! My virtual 10.
nv3
5-Apr-17 10:49am
View
No, it doesn't. Just whether the number is a power of two or not. The exponent could also be determined in a piece of linear code by using a 12-bit lookup table and three rsp. six shifts.
nv3
5-Apr-17 3:35am
View
First, of course, debug your code. Once you have done that, note that there is a much more efficient method of checking whether a number is a power of 2:
int x;
if (x & (x-1) == 0)
// yes, it is a power of two
I leave it up to you to prove why and how this little trick works.
nv3
14-Mar-17 12:52pm
View
Oops, didn't see that this was *that* old. Hopefully, Max got his hamburger stand running by now :-)
nv3
14-Mar-17 11:41am
View
So true! We all like to help if someone has taken reasonable effort and gets stuck. But we don't like to be abused by people who are too lazy. My 5.
nv3
14-Mar-17 11:33am
View
"Your neighbor Max is opening up a hamburger restaurant." -- That is not true. My neighbor Max is not opening a hamburger restaurant, nor do I have a neighbor Max, nor do I do your homework. If you don't like to solve tasks like that, then better go for another profession.
nv3
12-Mar-17 19:02pm
View
Take a look at:
fluxi>> .... >>IDN[i];
IDN is two-dimensional array. So IDN[i] is in itself an array! And the same problem somewhat further down in your code with IDNO.
nv3
6-Mar-17 4:17am
View
My 5. Good explanation.
nv3
3-Mar-17 11:12am
View
It happens to the best of us :-)
nv3
3-Mar-17 4:40am
View
Hi Jochen! I don't really agree. As the first operand (0) is false, the second operand (z++) must be evaluated and the expression result is always 0.
The actual question is: Will the post-decrement be executed before or after the assignment to z. In the first case, the post-increment to z is executed, then the expression result (0) is assigned to z -- thus overwriting the effect of the post-increment. In the second case, the assignment is first executed, then the post-increment will afterwards increment z to the value of 1.
To my knowledge, the C standard is not clear on the moment on which the post-increment will be executed. And I admit, I personally don't care. Nobody in his clear mind will write a statement like this in production code. Thus, again one of these questions that are purely academic.
nv3
16-Feb-17 5:33am
View
>>> You know as much about the code as the Manager does!
How else could it be. And the little we know is not enough to take a solid decision. If you are not experienced enough yourself you might want to hire an independent expert to take a look at your code and have him help you and the manager with that decision. That might save you all a lot of money in the long run and perhaps prevent a total disaster with a rewrite from scratch that doesn't work properly.
nv3
1-Feb-17 17:33pm
View
Very useful hint!
nv3
29-Jan-17 4:47am
View
My best guess is that MSXML will not allow you to find the line number of a tag. You will probably need to find another XML library or implement your own parser that keeps track of line numbers.
nv3
26-Jan-17 16:36pm
View
It is hard to tell what you are doing wrong without seeing your code. My best guess would be that you are confusing the representation of angles: Your pocket calculator takes probably angles in degrees; math functions in C++ take radians. To convert from degrees to radians use: degrees*PI/180.
nv3
22-Jan-17 7:42am
View
Where is your problem. Just post the fraction of code that you have problems with. I guess nobody will take the time to read and run your entire program. Get familiar with the debugger so that you can pinpoint the problem.
nv3
22-Jan-17 7:38am
View
You are welcome. Don't forget to accept one or more solutions that have helped you.
nv3
20-Jan-17 3:22am
View
The name "Fibonacci" is misleading. Those are not Fibonacci numbers, which have no term "+ Fn-1 * Fn-2". Hence the number series even grow faster than Fibonacci's series! Meaning: N cannot be chose very large and you will arrive at the limits of number representation in a 32-bit int.
nv3
18-Jan-17 8:04am
View
Well spotted!
nv3
18-Jan-17 8:04am
View
Oops, you are so right, Richard. Corrected that in my answer.
nv3
14-Jan-17 5:12am
View
And what exactly do you expect from asking a question in the "quick answer" section? Do you honestly believe that someone is going to volunteer to do the work for you, just because you are "running out of time"? If you are really running out of time, then don't waste it by such useless posts!
nv3
10-Jan-17 12:25pm
View
A brilliant answer - but apparently for a student who is obviously too lazy to read a manual, like so many on this site. My 5.
nv3
8-Jan-17 4:03am
View
Why don't you define an array for the desired output instead of printing it inside your algorithm. Your algorithm could fill that array and then you print its contents at the very end of main. That way you can even put your entire algorithm nicely into a separate function and have main just do the input and output.
nv3
7-Jan-17 12:30pm
View
I can't see that you have implemented my advice, except for the sorting, which is useless if you don't follow the other parts. You don't need an N x N array to store the links. That is highly inefficient if you have only N-1 links! Just the initialization of that array is taking quite some time. And the most time consuming part is that nested loop at the end of your code. Read my solution again and try to implement that. It avoids this nested loop.
And you still are using those syntactically incorrect array definitions. What compiler are you using? A standard C compiler will reject those. I assume you must be using some kind of C interpreter, or you code would not even compile!
nv3
7-Jan-17 5:43am
View
It is certainly okay to ask for help on a problem you are stuck with. But you didn't show anything of what you have tried so far, no idea of solution, no code, nothing. This website is swamped by questions of people who just try to dump their homework (or self assigned problems) without showing the least attempt of their own efforts. So show us what you have done so far and where exactly you are stuck. And show us some code for that (and code that at least compiles). The help you will receive here will be directly related to the amount of detail you show on your own efforts.
nv3
7-Jan-17 5:20am
View
You should not post the same question twice! I have taken a look at your previous question and giving you some hints on how to solve that.
nv3
7-Jan-17 3:55am
View
Don't repost!
nv3
6-Jan-17 4:42am
View
Can you post the code of your EFSM or at least the essential parts of it? Much depends on how your EFSM is organized. Depending on that you can just interleave the operation of multiple EFSM by calling their execute functions in a loop, or you will have to organize them in separate threads of fibers.
nv3
5-Jan-17 14:11pm
View
I totally agree. If OP new how to use a debugger he/she would not have posted this question, but found the problem.
nv3
4-Jan-17 5:24am
View
I guess he wants a queue, not a stack, Jochen.
nv3
3-Jan-17 14:44pm
View
Although the name might suggest it, string theory has nothing to do with strings in C! It's about physics.
nv3
2-Jan-17 19:02pm
View
5.
nv3
8-Dec-16 18:17pm
View
Well, it's your homework isn't it? So what good would it do you if we gave you the answer.
nv3
14-Oct-16 3:48am
View
Sounds like someone saying: I am a beginner in music and want to write an opera. Like Richard said, voice recognition is one of the most advanced things in computer sciences today. Start by programming simple programs first -- then after some years of practicing you can tackle one of the more complex problems.
nv3
13-Oct-16 3:56am
View
He is trying to access the first character of the first argument. *__argv[1] should normally do that. But in the case of a unicode application, windows doesn't deliver the argument vector in __argv, but in __wargv instead. That's probably why he got the access violation.
nv3
9-Oct-16 12:18pm
View
Your code did not show in the comment. Use the green "Improve question" button below your question to add your code.
The comparison should look like this:
if (fabs (x - y) < epsilon) {
...
}
And epsilon is the approximation margin you allow, for example 1e-8 if you are computing in double and your values are in the range of 1.
nv3
23-Aug-16 12:38pm
View
Some parts of what you are trying are still not clear to me. Are you really talking about 0.1% opacity, which means, the image is barely visible at all (or did you mean opacity 0,1, i.e. 10%)?
I understand that you are building kind of a video-player, which superimposes your watermark image over the video. Then you want to capture the resulting screen image and try to detect if the watermark image has been superimposed or not. Correct? If so, what is all that good for? Is that just an experimental setup to play with watermarks and their detection.
Lets assume, I understood your task correctly. Recognizing a watermark has nothing to do with face recognition. Consider how the watermark influences your image. It adds edges to the image, the edges contained in the watermark. Therefore you want to do edge detection on the image and compare the edges with those of the watermark. Unfortunately, the result will also contain the edges from your original image. So you can only expect the just some of the edges in your new image will come from the watermark. Therefore the difficulty lies in finding a reasonable threshold of how many of the watermark edges will be required to be found in order to call it a positive match.
Hope that sets you onto the right path.
nv3
4-Aug-16 18:16pm
View
None of your printf statements prints a number. So how do you expect your code to print the desired pattern? Also, look at the expression in the if-statements:
j>=i && j<=c+i
With c being always positive this expression is always false.
My suggestion: Run through your code with a debugger and see what it does, line by line. And compare that with what you were expecting. You will soon see, where the various mistakes are.
nv3
30-Jul-16 3:21am
View
Things don't run this way here. We don't do you homework. At least you have to attempt to solve it yourself and show the code that you have arrived at. Then you may ask a question regarding a particular problem that you have run into.
nv3
29-Jun-16 11:27am
View
My 5. And I guess there is even a way to avoid iterating over all 2**16 possible IDs. But that requires looking a little deeper into the exe file format.
nv3
22-Jun-16 18:19pm
View
+5
nv3
12-Jun-16 4:46am
View
This is your fifth question and you still have not learnt to format your question properly. It's not that difficult. Just enclose your code with a <pre> ... </pre> tags, which you can also do by hitting the "code" button above the edit window.
nv3
11-Jun-16 11:23am
View
Solution 1 tells you how to do this. But note that using a recursive function for reversing the order of a linked list is not a good idea. Imagine your list contains a million entries! You would be putting a million stack frames on your stack for the million-deep nesting of your revPrint function. Most likely, your stack will overflow and your program crash.
A much better method would be to use a double-linked list, in which you simply start at the end and follow the backward links.
I suspect, this is homework and your teacher has given you that as an assignment. If that is so, tell your teacher that this was a rather bad example. There are better examples for recursion that really make sense.
nv3
9-Jun-16 11:55am
View
When the compiler is evaluating a constant expression it is not your code that is being executed, but the compiler's. The compiler is just interpreting those parts of your source code that are constants and hence can be dealt with at compile time. YOUR code, i.e. the output of the compiler, is only being executed at run time -- well, that's why it's called run time, isn't it.
Anyhow, I don't want to disturb your view of the world. May you get happy with whatever view you have.
nv3
8-Jun-16 19:44pm
View
Sorry, but code is never executed at compile time. That's why it's called "compile" time. But the compiler may evaluate expressions at compile time and thereby optimize performance. I guess that is what you mean by "code being executed at compile time". Yes, this is kind of running some calculations already at compile time vs. at run time. It's just not called "executing code", but "evaluating" expressions by the compiler.
nv3
3-Jun-16 10:01am
View
Have you noticed that you let the indices i and j starting from 1 instead of 0? You corrected this in the x and y loop, but forgot i and j.
nv3
30-May-16 11:12am
View
And what was the error message on your second attempt, the one with the '&'?
nv3
2-May-16 17:20pm
View
The ambiguity is not between the precedence of the + or ++ operator. In the statement
z = x + ++x;
there are two operands of the + operator: x and ++x. Which one of these operands is to be evaluated first is undefined by the C++ standard and hence up to the compiler implementation. If the left operand (x) is evaluated first the result is: 6 + 7 = 13. If the right operand is evaluated first, the result is 7 + 7 = 14.
Operator precedence in this case only says that the pre-increment must be executed before the addition takes place. It does not however state whether the left subexpression (x) or the right subexpression (++x) is to be evaluated first.
nv3
2-May-16 13:58pm
View
You know, I always wanted to do someone else's homework. I am so glad you posted this question. Otherwise I would not know what to do with my time. And what a great coincidence that you yourself don't find the time for it. So I will start right away getting it done for you ... Is that the kind of response you were expecting?
nv3
1-May-16 10:08am
View
I don't agree, Peter. The result of the original example is undefined as is it up to the compiler when to evaluate the pre-increment operator, before or after the evaluation of the left operand (x). If the compiler evaluates operands left to right, the result will be 13, and with right to left 14. The fact that you have removed your solution (1) tells me that you have recognized your mistake.
nv3
1-May-16 7:29am
View
I seriously doubt that this explanation is correct. The ++ operator must not be split up by a space! The correct explanation in my opinion is that the evaluation sequence of the operands x and ++x is done right to left by the compiler and results in 7 + 7.
nv3
29-Apr-16 10:05am
View
Basically the same question as in http://www.codeproject.com/Questions/1096602/How-can-I-write-a-function-that-returns-true-only.
Why didn't you follow my advice on the last question?
nv3
28-Apr-16 19:14pm
View
You'r welcome. And a final hint: Just try your suggested code out. Write a couple of tests in you main function and see whether your lowercase function returns what you expect.
nv3
28-Apr-16 19:06pm
View
(c >= 'a') && (c <= 'z')
Is an expression. What data type has this expression? Here are some examples:
1 + 3 * 5 -- this is an int expression
1 + 3.1 * 5.1 -- this is an expression of type double
bool a, b;
a && b -- this is an expression of type bool
Now take your C textbook and find out what data type (c >= 'a') is. The operator is >=. That should give you a clue.
When you know what type (c >= 'a') is you should be able to answer what type
(c >= 'a') && (c <= 'z')
is.
nv3
28-Apr-16 18:40pm
View
As this is obviously homework I will not provide you the answer. Just a hint:
(c >= 'a') && (c <= 'z')
is an expression. Now, what data type has this expression? And then you know, which values it might assume. If you return this value, does it do what you want?
If you answer those questions you will find your solution.
nv3
24-Apr-16 18:16pm
View
Who could keep you from asking questions. Its just that not all questions might be answered.
nv3
24-Apr-16 4:13am
View
Your program should actually not even compile. The C language does not have dynamically sized arrays. Hence, a construct like
char name[entry][19];
is not allowed. All array dimensions must be constant and known at compile time.
There are ways you can allocate your arrays with a variable size, but now I would simply specify a reasonably large size instead of entry.
nv3
20-Apr-16 18:43pm
View
Probably the correct solution, Dave. Why don't you go ahead and post it as such.
nv3
20-Apr-16 16:07pm
View
Bad luck! Nobody is going to do your homework. And if you are short in time then probably not, because your teacher didn't give you enough time.
nv3
19-Apr-16 3:34am
View
You didn't understand my question. Yes, use the Hough transform. When you have a set of (x, y) points you can directly use it -- what's the problem?
nv3
18-Apr-16 6:12am
View
If you have a set of (x, y) pair, what exactly is it that keeps you from applying a Hough transform?
nv3
12-Apr-16 2:52am
View
Not to my knowledge. But perhaps one of the SSE2 gurus can comment on this.
nv3
11-Apr-16 6:58am
View
1. Format your code properly when posting a question. Use the code tab to insert <pre> tags so that your code is better readable.
2. Use a debugger to find out what's going wrong.
nv3
11-Apr-16 6:47am
View
You have to show your code for someone being able to help you. Yes, _mm_packs_epi16 does pack your 16-bit integers into 8-bit integers, but with saturation. That means that for example a value of 346 (represented as bytes 90 1) is converted to 127, which is the highest signed 8-bit integer. Is that what you mean by "result is strange"?
nv3
9-Apr-16 11:33am
View
"I need code" is not a question. And code for face recognition is everything, but simple. This is not the type of question that fits a "quick anwser" forum.
nv3
9-Apr-16 11:31am
View
Yes, and he forgot the parentheses around the two values.
nv3
9-Apr-16 11:30am
View
My 5! And I think we should put up a big sign: TOUGH SHOULD USE YOUR DEBUGGER! That advice fits 80% of all the questions here :-)
nv3
8-Apr-16 16:02pm
View
I don't know who voted Richard's solution down. Actually, this is the way to go in my opinion.
@SpicaX: Create a class that serves as base class for all your values. For example, you might call it CellBase. Then derive another class for every type you need, for example, CellInt, CellDouble, CellText ... The CellBase class should contain virtual functions as: ToText, FromText, GetType, ... and the derived classes should contain overrides for those virtual functions that implement the specific types behavior. Your array of pointer would of course contain CellBase* Pointers. Does that make it clear?
nv3
8-Apr-16 12:19pm
View
For _mm_load_si128 to work correctly the buffer needs to be aligned on a 16-byte boundary. And your buffer, just allocated on the stack, probably is not aligned or just by chance. If you don't know what "alignment" means, google it. Without that knowledge you will not be able to get far with SIMD instructions.
nv3
7-Apr-16 18:11pm
View
That's possible, although a bit tedious. Just use a 12-stage if-construct, a la
int dayInYear = 0;
if (month == 1) // January
dayInYear = 0;
else if (month == 2) // February
dayInYear = 31;
....
That's not nice, but it'll work.
nv3
4-Apr-16 8:09am
View
Your comparison of a coal mine with learning is really great. I love it! My virtual 5.
nv3
29-Mar-16 6:32am
View
So, I understand, you found the reason that causes this difference. Why don't you post a question then?
In case you have not found the reason yet: It is the implicit alignment that the compiler does, which causes this problem.
nv3
26-Mar-16 13:42pm
View
Danke!
nv3
21-Mar-16 3:49am
View
Thank you!
nv3
20-Mar-16 11:44am
View
Because the linking of one node to the other was not correct. See my explanation above.
nv3
17-Mar-16 6:01am
View
Good idea, Jochen.
nv3
12-Mar-16 2:53am
View
Your (1) is as good a reason as any :-) My 5.
nv3
6-Mar-16 10:13am
View
Nice explanation!
nv3
4-Mar-16 2:50am
View
Thanks Philippe!
nv3
1-Mar-16 16:25pm
View
Focus on all that you need for your project -- as simple as that. Nobody can tell you what patterns you are going to need in your project. You will know, once you need them.
nv3
23-Feb-16 19:14pm
View
Your question is not clear. What do you mean by: convert fraction part to int? Obviously you want to interpret the fractional part in decimal - as your example shows. As the fractional part is internally represented in binary format, the conversion to a decimal representation will deliver an infinitely long sequence of fractional digits (in many cases). Functions like printf generate a rounded representation with a certain number of digits. So, do you always want the int to be equal to the first N digits of the fractional parts?
The other question is what you mean by linear or log time? With regard to what? The number of digits? You only have one value to operate on.
nv3
23-Feb-16 10:06am
View
Instead of doing your homework you hunt for some code in the internet and don't even want to invest the time to understand it. You will probably not get very far in this way. Good luck!
nv3
23-Feb-16 9:28am
View
How do you write a C program ...? That's simple to answer: Use a text editor or even better, use an IDE (integrated development environment) like Visual Studio. Think about the algorithm, write the code, and finally test it in a debugger. That's how everybody does it :-)
nv3
22-Feb-16 9:32am
View
Good analysis, Jochen!
nv3
21-Feb-16 15:10pm
View
If you are as careless with macros as the spelling your heading, macros will in the long run kill you.
nv3
17-Feb-16 8:48am
View
Yes, that seems to be the problem. Good shot, Jochen.
nv3
16-Feb-16 3:17am
View
Yes, I understand what you did. And what bug are you talking about? We need more precise information in order to help you.
nv3
15-Feb-16 18:32pm
View
Looks to me that you are creating a so-called ragged array (google it!). And from first sight it looks your code is correct, except that you should use delete[] in all your loops at the end, not only the j-loop.
nv3
15-Feb-16 18:22pm
View
Do you think you are the only one who is in a hurry? Why should anybody take the time to answer you if you don't even have the time to phrase your question well and clearly?
nv3
15-Feb-16 11:24am
View
Check the ID of your combo box. Is it really IDC_COMBO1. Other possible issues:
- code is not executed from within a member function of the window that contains the combo box
- you are executing the code at a stage where the controls of the dialog have not been created yet
nv3
14-Feb-16 5:47am
View
Well, I think that is not entirely correct. The order of the evaluation of the << operators is dictated by the left associativity of the << operator. So, first
cout << *p
must be evaluated, then
... << ","
and so forth. Anything else would not make sense, because then the output sequence would be unpredictable.
The clue here is that the arguments of the << operators are expressions themselves and the compiler is obviously free to evaluate these expression in any order before feeding them into their respective << operator. A very subtle point indeed, which I would not have expected.
The lesson to be learned: Never put anything with a side effect into a cout chain!
nv3
11-Feb-16 8:16am
View
Bingo!
nv3
9-Feb-16 4:23am
View
His assignment was to fill in the dotted spaces ;-)
nv3
8-Feb-16 18:10pm
View
Nice, although strictly speaking you did not conform to the request of not using arrays -- which will be easy enough to change.
nv3
8-Feb-16 15:23pm
View
My 5.
nv3
5-Feb-16 19:09pm
View
There are several lines in your code that are not even syntactically correct. Like this:
for(i=0;i {
X[i]=-1;
Y[i]=-1;
and this
for(i=1;i< max;i++)>
So it will not even compile! If you don't take the time to present your problem properly, why would anybody else spend time helping you?
nv3
2-Feb-16 4:57am
View
Thank you, Sergey.
nv3
1-Feb-16 14:33pm
View
Is it possible to build a car that runs with gasoline? -- Your question is as ridiculous as that. And if you really have to ask that question, I doubt that you will not be able to complete the project yourself.
nv3
31-Jan-16 18:19pm
View
It's homework and it's easy. Here is a hint: Where in your code are you adding the values up? And are you printing the sum or just the 48 values? In which loop would you have to place your print statement if you wanted to print only the 12 sums? How should you nest your loops, so that the print loop becomes the outer one?
nv3
31-Jan-16 9:45am
View
Obviously that has to do with the special protection of the \Windows directory, which probably hosts your operating system. My guess is that the code in remove_all is not handling some return code correctly and then crashes. I would compile in debug mode and step inside the remove_all function to see what it's doing.
nv3
30-Jan-16 8:33am
View
My 5, Sergey. I particularly like your comments about design patterns. This entire design pattern hype makes beginners often thing that design patterns were kind of a magic spells that have to followed word by word. They don't realize that basically everybody programs with design patterns, sometimes without knowing it.
nv3
29-Jan-16 5:34am
View
No, there isn't. Splitting the file into packets and sending them is all you can do. BUT: You can possibly improve on the details like packet size, overlapping the file and network operations etc..
nv3
27-Jan-16 19:08pm
View
And you honestly expect a "quick answer" to this question of all questions! Debugging a system of multiple processes, each of the multi-threaded is going to be tough if the applications are not designed in the right way in the first place. And if they were, you probably wouldn't post this question.
I would start out by looking at the code in a code review and analyze each of them for potential problems. The debugging tools needed pretty much depend on which kind of crashed you are observing. Try to make each process as independent from all others as possible. And finally, if you are not an experienced developer yourself, get one on board. Trying to give you a good strategy at hand is like trying to describe how to fly an airplane safely in ten words -- better get a pilot on board.
nv3
26-Jan-16 5:35am
View
Many good points, Philippe!
nv3
25-Jan-16 6:20am
View
Thanks Richard! After years of being with codeproject I have never used markdown knowingly. And I didn't expect it to apply inside a <pre>-tag code block. That's kind of strange.
nv3
25-Jan-16 5:03am
View
Yes, this is strange. I think the problem with the hash character not showing correctly might be a problem of the codeproject site. It showed the correctly in preview, but then messed it up on the final page. -- By just putting a space in front of the # I could "convince" it to do it correctly.
nv3
24-Jan-16 13:05pm
View
You certainly meant the other way around, did you.
nv3
24-Jan-16 6:04am
View
Obviously you also have a definition of the CCDCDirectControls constructor in file bmpLoadView.cpp.
nv3
23-Jan-16 13:20pm
View
Probably not. This task is so incredibly difficult that probably no one else except yourself will be able to do that. So, the world is waiting for you to solve that problem.
nv3
22-Jan-16 7:31am
View
My 5 for sending a beginner in the right direction. Never build on undefined behavior. To OP: Instead of guessing what a compiler might do or not, just put that missing return statement in at the end of that function. Anything else is a waste of time.
nv3
15-Jan-16 6:38am
View
Sorry, but the errors are clearly visible to everyone who is beyond the beginner stage.
nv3
14-Jan-16 17:23pm
View
You should use the grren "Improve solution" button to amend your question. I have done that for you now.
To your problem: You are mixing up what a base class and a derived class is! In your example, CDerive1 and CDerived2 are in fact the base classes and CBase is derived from them. By using the wrong terminology you are not likely to get an answer to your actual problem, which I have not understood by now. Try to rephrase your question using the correct terminology.
nv3
14-Jan-16 17:13pm
View
Yes, sir! 5.
nv3
14-Jan-16 13:10pm
View
So. Get to work. Don't expect others to do your homework. If you run into trouble, you might come back here and ask a question about your particular problem. But frankly asking others to do your homework will get you nowhere.
nv3
2-Jan-16 11:58am
View
This is just a fragment of the entire program. What makes you believe that the bug is in there. And what is the error you get? We can't see you screen. The more information you give, the larger the possibility that someone can help you.
nv3
29-Dec-15 11:06am
View
Thanks for this comment, Albert. Good point.
nv3
27-Dec-15 16:17pm
View
Thanks!
nv3
23-Dec-15 3:42am
View
See http://stackoverflow.com/questions/31287207/opencv-svm-training-data for the solution of your problem.
nv3
18-Dec-15 18:24pm
View
My 5 - and you gave good general advice (even after visiting the pub).
nv3
17-Dec-15 16:00pm
View
Now what, C or JAVA?
nv3
4-Dec-15 6:22am
View
I have posted my comment as answered so that the question is closed.
nv3
4-Dec-15 4:05am
View
Operator overloading only applies to C++ functions and not to macros. Consider that macros are expanded by the preprocessor and and are hence are no longer visible to the following compilation steps. Although macros might look like functions to you they are in fact not.
nv3
12-Nov-15 18:03pm
View
A beginner might miss your humor in suggesting something like that - and then use it in production code ;-)
nv3
11-Nov-15 3:05am
View
I don't think that the error can be found by looking at the few sources you have posted in your question.
nv3
7-Nov-15 12:04pm
View
Your statement is not true:
10 * -120 + 13 * 100 = 100
So there is obviously more than one combination of x any that fits the rule. Or you should have stated that x and y need to be non-negative.
nv3
28-Oct-15 5:01am
View
Do you want to say: Although it thought the DrawNeedle function would paint a needle over the Speedometer scale, the needle did not appear and just the speedometer scale appeared, unmodified. Is that what you observed? What have you tried to resolve that? Have you tried leave out the rotation step and just display the needle unrotated?
nv3
27-Oct-15 12:15pm
View
And what exactly do you mean by "I was unable to do so"?
nv3
26-Oct-15 4:10am
View
Start with your Node struct. You just have to convert the classes member functions into C functions. The member data of the class goes into a separate struct, a pointer of which you pass as the first argument of each of these C functions.
nv3
24-Oct-15 11:56am
View
Okay, that's your homework. Let us know when you are done and which problems you encountered -- of course combined with the code you have produced so far.
nv3
23-Oct-15 16:11pm
View
With just looking at a tiny fraction of the code involved it seems rather hard to tell what exactly went wrong.
nv3
21-Oct-15 10:49am
View
Okay, didn't know that you wanted to use it for professional work. In that case you might want take a look at UltraEdit. It's not for free, but not very expensive either. And they have a compatible IDE called UltraStudio. I haven't checked about #define high-lighting, but I guess it's worth to download their free trial.
nv3
19-Oct-15 16:56pm
View
Whoever it was should have had the courage to comment on his downvote. So I hope you don't get frustrated by this.
nv3
19-Oct-15 9:38am
View
I guess the author didn't like your answer -- but wrongly so. My 5.
nv3
12-Oct-15 4:34am
View
"far too expensive for that" -- VS is for free if you download the non-pro version. And the editor in VS is excellent. Why don't you simply download the free version of VS and work with that. It would even allow you to do a compile run.
nv3
7-Oct-15 13:48pm
View
And git is also easy to run locally.
nv3
6-Oct-15 4:01am
View
It would help if you told which error you are getting. How could we guess.
nv3
4-Oct-15 18:37pm
View
Just for clarification: Did your tutor ask you to implement the TCP protocol based on an existing UDP implementation, or did he want you send some packets via TCP (which as he commented uses UDP internally to do the work)? The latter is a lot easier. Implementing the TCP protocol is no beginners task and I can't imagine you tutor wanting you to do that while is out of the country for a couple of days.
nv3
4-Oct-15 17:51pm
View
This is not a 5-minute job, but more like a real project. I would start by reading the RFPs on TCP and google for other implementations of TCP. After understanding the various concepts and problems, I would start writing a first version.
As Chill60 pointed out, this is a quick answer forum. Talk to your tutor or teacher, he is the one who can most likely help you.
nv3
4-Oct-15 17:47pm
View
Tell your teacher that taxes are not calculated on net income, but on gross income :-) As for the programming task at hand: Just look into your course notes. If you can't do this simple assignment, I would advise to better find another career.
nv3
30-Sep-15 17:49pm
View
Who says int is always 2 or 4 bytes? On 64-bit machines it is often enough 8 bytes long. And makes struct x longer than 8 bytes.
nv3
29-Sep-15 18:44pm
View
I accept your good intents and realize that a teacher's life is tough sometimes.
nv3
29-Sep-15 18:41pm
View
My 5 for detecting the error in the example table. It took me quite a while to figure that out.
nv3
29-Sep-15 18:35pm
View
Well, it took me half an hour to understand the facts and about one minute to solve it :-) And the wrong example table you gave in your answer didn't exactly help :-)
nv3
29-Sep-15 18:31pm
View
Your example table is unfortunately incorrect. It should read:
day aliens eggs
0 1 3
1 1 6
2 1 9
3 1 12
4 1 15
5 4 24
6 7 42
7 10 69
That would have made it clear. In your example the hatching it is not 5, but 4 days! I guess, that confused everyone.
nv3
29-Sep-15 17:15pm
View
First of, the problem is not "basic" if you obviously need several attempts to correctly state the question, including all the things one is to ignore to come to your solution. Secondly, perhaps it this insistence to first understand a problem fully and not jump at conclusions that makes some users of the forum real software professionals. Often it is the correct understanding of a problem that is the difficult part. :-)
nv3
30-Aug-15 4:06am
View
Try "char* hombres[] = {"Ramiro", ...};" which is better anyway as it doesn't limit the lengths of your names.
nv3
4-Aug-15 10:39am
View
That is one of the nice features of C++11.
nv3
4-Aug-15 8:12am
View
That is exactly what the inner loop does. It accesses in turn each element of the vector<int> c. Of course you could write this loop also as:
for (int idx = 0; idx < c.size(); ++idx)
... do something with c[idx] ...
Is that what you mean?
nv3
4-Aug-15 7:38am
View
See my answer to your previous question, in which you have asked the same. I think the nested loop is already pretty simple and can't see how this could be done with even less code.
nv3
4-Aug-15 7:36am
View
Please, see the second amendment to my answer.
nv3
4-Aug-15 4:14am
View
You are welcome. Hope it helped.
nv3
4-Aug-15 4:14am
View
Deleted
You are welcome. Hope it helped.
nv3
4-Aug-15 3:55am
View
See the amendment to my solution.
nv3
17-Jul-15 17:36pm
View
The line "std::vector
b;" tells me that you are not showing us the exact code of your example. 'b' is not a type. Hence that statement would not compile. I assume you meant to write: "std::vector
b;".
And what is so unusual about the output? Can you elaborate a little more what you actual question is.
nv3
4-Jul-15 14:55pm
View
My 5! Why don't you post it as an answer?
nv3
2-Jul-15 9:07am
View
I don't know if I understood your English correctly. The pre-processor looks exclusively at the pre-processor statements, i.e the # lines and expands them. It writes the expanded output to a temp file (or passes it to the compiler in another mode efficient way). Then the compiler reads that expanded source and does its job, including generating error messages.
nv3
27-Jun-15 14:32pm
View
Thanks!
nv3
27-Jun-15 1:19am
View
My 5!
nv3
23-Jun-15 4:53am
View
You did a whole code review. 5.
nv3
22-Jun-15 16:53pm
View
You just convinced me that basically I will never be able to convince you. Let's keep it at that and simply agree that we disagree.
nv3
22-Jun-15 16:29pm
View
Sergey, with all due respect. I don't doubt that two threads in two different processes can make trouble by accessing the same resource. Of course that is true. I just want to say that such a situation is not normally called a "thread-safety" issue, but are titled generally as "concurrency problem" or "race condition". The term "thread-safety" is my opinion reserved for threads within the same process. If a programmer calls the library he has created as thread-safe, he normally can only speak with regard to thread within the same process.
nv3
22-Jun-15 12:20pm
View
Wouldn't you agree that a single-thread program is inherently thread-safe? At least that's what I have been thinking over the last 20 or so years. And if I read the Wikipedia article on "Thread Safe" that understanding seems to be correct. Just to quote the first sentence:
"Thread safety is a computer programming concept applicable in the context of multi-threaded programs" -- Wikipedia
Sorry, I don't subscribe to your opinion that threads in different processes can produce thread-safety issues with regard to each other.
nv3
22-Jun-15 11:57am
View
With the statement "The concept of thread-safety does only apply to threads within a single process" I mean to say that only threads within the same process can create problems that one would call "thread-safety" issues. While thread in different processes can create concurrency problems, which however are not called thread-safety issues. Sorry, I can't see why this statement would be "formally totally untrue".
nv3
22-Jun-15 11:43am
View
Your statement that thread safety applies to multiple threads "no matter if they are in the same process or different processes" is in my opinion not correct. The term thread safety applies *only* to threads within the same process.
Of course, threads in different processes can produce race conditions when accessing the same system resources, but these are normally not called thread-safety problems. For example, two processes, each single-threaded, can cause such problems and it would be absurd to speak of thread-safety issues with regard to single-threaded processes, don't you think.
As a consequence, thread-safety is never an issue in single-threaded processes -- which makes sense after all.
nv3
22-Jun-15 11:30am
View
Sergey, you are absolutely right about the first line. It should read "threads" and not "thread" in there. (corrected)
About possible conflicts of activities in multiple processes: Yes, multiple processes can produce race conditions when dealing with the same operating system resources. But these are usually not called thread-safety issues, but concurrency issues.
nv3
20-Jun-15 17:33pm
View
Or better cast to signed char, as int is signed as well? My 5.
nv3
15-Jun-15 3:36am
View
Looks like you have to instantiate the serialPort1 object first.
nv3
13-Jun-15 9:14am
View
In the second program you are trying to declare a global variable inside a function and that is a contradiction. That is probably what the error message says you are getting.
nv3
13-Jun-15 7:38am
View
To define a global variable write the definition outside the scope of a function, give it an initial value, and DO NOT us extern. In all other places that want to use that same variable use extern and no initialization value.
nv3
7-Jun-15 16:54pm
View
Thanks, Andreas!
nv3
7-Jun-15 5:54am
View
If you call your function with timeout=30 the timeout will be set to 35. That doesn't make sense. This is not the cause for the problem you describe, but it indicates the general sloppiness the code is written in.
As for the memset: It clears 4 or 8 bytes (depending on compilation settings). Remember that data is char* and sizeof(data) does not reflect the size of the array passed! This is also an indication that this code was written by someone without a clear understanding of C++.
Your question was: "Is this code reliable" and from what I have seen my answer is: No.
If your question is: Why does the read request sometimes timeout? I have no idea. It will probably take some debugging to find out.
nv3
2-May-15 9:08am
View
Next time, please format your code properly with <pre> tags. I have done it for you this time.
Now, what's wrong with your code? What is your question? We cannot see your screen. So you have to be a little more specific than just posting the question of your homework.
nv3
30-Apr-15 17:22pm
View
You are angry about my comments? Fine. Take all your anger and pick up a good C++ book and show the world that you are able to accomplish something.
nv3
28-Apr-15 18:23pm
View
I meant the "... is left as exercise" :-)
Show More