Click here to Skip to main content
15,178,422 members

Comments by armagedescu (Top 120 by date)

armagedescu 28-Aug-21 7:43am View
   
If is that you say, then it is the difference between i and index_arr[i].
armagedescu 28-Aug-21 7:40am View
   
I need to know how exactly OP defines it. I'd like to understand what exactly he expects to see.
armagedescu 28-Aug-21 7:39am View
   
How do you prove the indices are not sorted correctly? Provide some exact detail on what is the actual behavior and what is expected behavior in simple words that can help to spot any problem. A short sample of what your code does and that you actually expect, with some explanations.
armagedescu 28-Aug-21 6:05am View
   
Ok.
>>just can't decide on the API
Any API which is standard. Especially any part of STL that is not on experimental is a good choice. That will not impose any special prerequisites and thirdparties to any user which is not you.
>>Still, I want my function to be constexpr. I don't have any problems with implementing
I am curious. Are you using any kind numeric database? Will you make this library public?
armagedescu 27-Aug-21 11:29am View
   
>>This question is opinion-based
That's classification on stackoverflow.
>>The easiest solution would be to just return a std::vector of pairs {prime, power}:
no it is not. It is std::map.
>>but I don't want to perform any allocations:
what is exactly the reason for that?
>>I don't want to depend on any external library.
STL is standard library, it is not external. Use any part of STL that is not experimental.
>>I want the function to be constexpr
constexpr doesn't bring any performance improvements unless it can be calculated at compile time. Your problem by definition run time, not compile time. You even should take in consideration dynamic programming.
armagedescu 27-Aug-21 11:10am View
   
What is the exact meaning of the distance colum after ascending sorting? In which way exactly it is incorrect?
armagedescu 25-Aug-21 8:31am View
   
Any for/while loop can be replaced with a recursive call to current function. Think of iteration as a function. Instead of iterating it can be chained. Practically it doesn't make much sense unless your problem is recursive.
armagedescu 23-Aug-21 12:38pm View
   
Anyway I will delete all my replies shortly because I am not intending to share the non technical comments, that's not a psychology forum. These comments were intended to build a discussion, but this is not the right place for such discussions.
armagedescu 23-Aug-21 11:41am View
   
Deleted
On stackoverflow the 3 "Close" votes reasoning might be: duplicate, offtopic, opinion based, missing details, but never because of being old.
>> If a question receives 3 "Close" votes it will be closed to further answers unless re-opened: 3 "Reopen" votes and question will be re-opened.
>> This forum is a "Quick Answers": never encountered such a strange rule.
>> that is your right: even more strange, why someone should go against them?
>> If you choose to ignore him: I choose to discuss about that. All is about constraining to rules that do not exist.
armagedescu 23-Aug-21 10:12am View
   
Deleted
Be attentive. On stackoverflow is even a special badge: Necromancer. And it is silver badge, not as good as gold badge, but better than bronze badge. Copy/paste from stackoverflow:
Necromancer Answer a question more than 60 days later with score of 5 or more. This badge can be awarded multiple times.
>>They lock off questions to: never believe that. The review happens for everything, questions, first answers, late answers. Never a question is closed because it is old. And better responses are accepted even to ancient questions, moreover, upvoted regularily if correct.
armagedescu 23-Aug-21 9:50am View
   
Deleted
In fact that's not me who was the first to ascribe motives to comments. There are the motives mvps ascribe to correct answers, which 'are going' against some missing rules, and taking down them. Try being friendly the other way, accept the response.
armagedescu 23-Aug-21 9:13am View
   
Deleted
Your attitude looks very personal. You are trying to impose some own rules, that this forum doesn't have. Please refrain in the future.
armagedescu 23-Aug-21 8:47am View
   
Deleted
Also, I don't understand that much concern about the reputation. It looks more like hunting updates to be first to answer. That's why some questions never gets answered.
armagedescu 23-Aug-21 8:44am View
   
Deleted
A troll? That's the reply to only correct response? This is what is making a forum toxic. A response is knowledge base. Someone asks google, finds the question and the response. Response to unanswered question makes lots of sense. See stackoverflow, there the response to old unanswered question is welcomed.
armagedescu 22-Aug-21 13:39pm View
   
Deleted
Your reply looks much more than personal. So, keep it personal and don't reply, since this is the only correct response, and no one responded until now. You can downvote, is up to you, I don't care, downvoting wars is not my style. Since codeproject doesn't prohibit answering to old questions, I will respond whenever I consider useful to respond.
armagedescu 22-Aug-21 5:15am View
   
So, should I not respond just because of that irritates someone who is hunting updates? That looks very personal.
armagedescu 22-Aug-21 5:09am View
   
Really? Looks like very personal attitude.
armagedescu 12-Feb-13 4:23am View
   
Deleted
I've made a search to find where I claimed "never", and I found only one occurence. And this occurence has nothing to do with macros. So, don't attribute to me things I did not say. Moreover, I've used macros many times in different projects. And also used them in a public project, placed on codeproject. These are very specific usages, it is not your case. Macros was never replacement for implementation.
About upvoted answers, take a look. No one advised you to use macros. Keep in mind, all suggested solutions there have no macros.
About Boost, DirectX, MFC, ATL or anything like that. You are not author of any of them, so don't tell who agrees and who not. Ask any of authors of that libraries, and all of them will tell you to not use macros, at least in the way you are using them. Yes, there are some very specific tasks when better to use macros, but this is not your particular case. In your particular question, this is good only for practice in writing macros, but nothing more.
armagedescu 8-Feb-13 11:03am View
   
Deleted
Hey, there is not about reading comprehension, there is about programming skills, which is far not your strongest point.
About Java, you big fail, because byte code is compiled just in time (JIT), and is more than ten years since java does that.
About German\Japanese\French you again missed the point. I don't know how many languages do you speak, but it does not amtter, because we are talking C++, which like any kind of programming is far not a strong point of you.

BTW, I don't know if "Epic Fail" in your signature is your alias or your real name, but it describes very well yourself and your programming skills.
armagedescu 3-Jan-13 12:07pm View
   
So, as I see, there are two problems.
1. Program can't be compiled because compiler crashes.
2. If compiler can compile the program, then the program crashes at runtime.
In both cases seems to be like bugs in VisualStudio 2010 and above.
armagedescu 3-Jan-13 5:25am View
   
Is not unhandled exception. It is Access Violation while calling of a member function by invalid pointer.
armagedescu 2-Jan-13 11:14am View
   
I think the destructor of std::wstring does that. The problems appears with constructing/destructing and new/delete operators. Seems like arrays of std::function are not supported, or not well supported yet.
armagedescu 19-Dec-12 3:11am View
   
Deleted
>>>> C# code compiles to IL, the JIT compiles the IL to
>>>> machine code at runtime. (The newest C# compiler Roslyn is written in
>>>> .Net too, likely, C#.)
>>>> http://msdn.microsoft.com/en-us/vstudio/roslyn.aspx
So what? There are lots of technologies doing that. Is not only C# and Java.


>>>>>> There are very few real advantages to using C++.
>>>>>> 1. Cross-Platform Support
The portability is not the strongest point and the real advantage of C++.

>>>>> You can expose ofstream\ifstream for flexibility, and STILL provide high level functions in the STL.
You've just discovered America

>>>>> You really need to work on your English.
With you I don't speak english but I speak C++. This is why I work with british, french, japanese, german, ... programmers and we all understand each other. By the way, how many languages do you speak?

>>>>> C++ could easily ADD these new functions using the STL streams.
>>>>> std::write_file(path, text);
>>>>> std::read_file(path);
>>>>> How would that hurt C++?
What for? There is no need for that. And if appears the need, is not a very smart thing to add small wrapper what will do that in the application. It does not make much sence to add them to standard library.

>>>>> I know various languages x86 ASM(reversing), C\C++\C#\Python\Perl\Basic,
>>>>> and numerous scripting languages from my game modification days,
>>>>> NWScript, Morrowind\MWSE, Oblivion\OBSE, Skyrim\SKES\Script Dragon,
>>>>> and various other game related scripting languages, etc,. (Also, JS\HTML\XML, etc,.)
So what? Trolling again? A lot of people suck at their job and have been doing with lots of technologies
armagedescu 18-Dec-12 6:04am View
   
Deleted
---ups, text got trunkated.

>>>>> I'm not a master of them all,
>>>>> Stop telling me I'm not.
Please stop trying to impress people. You would better trust good advises from experienced programmers until you get deeper understanding and knowledge of the technology.
armagedescu 18-Dec-12 5:56am View
   
Deleted
>>>>> Assembly language is just a standard, assemblers generate code that meets this standard, as does C++.
Aa, yeah, you've just discovered America


>>>>> But, okay, Boost is WAY better, so much so, that Boost is being added to the STL and treated as the new STL in C++ programming.
I reiterate that I said. You are not Bjarne Stroustrup. Before copypasting some opinion from the internet as yours, you should at least know that you are talking about. You do not know STL, and Boost neither.
Boost is not a replacement for STL. There are added some new functionalities, but old ones remains 99% the same. And no one replaces the other. STL is meant to feet the needs of high level programming, and also to feet the possibility of low level fine tuning, when working just in C style. You can refer the sample of code written above.

>>>>> That's why the STL sucks, code, is code, is code, no matter what the language.
Before talking about STL you have at least to know it.

>>>> If C# can do this in 2 lines of code, why can't C++\STL?
C++ is other language, having its advantages. And advantages of C++ makes it to be used and developed, even if some languages are easier to use. This is why most of widely used applications are made in C++. And this is why tons of killers of C++ that appears over decades, haven't yet killed even a millimeter of C++. Moreover, C++ is still being developed, modernized and prepared for using in the future.
In C# some things takes less code to write, because lots of libraries written in C++ which it uses. Without these libraries, you would not even be able to open a file in C#, or to resize an array.

>>>>>>>>> So, we have two languages, in the end, both accomplish the same\similar task,
>>>>>>>>> but one does it faster(RAD), with better syntax, less errors, etc,.
Not everything in the world is RAD. C++ is used because of other advantages. What browser are you using?

>>>>>>>> That's it, I don't care what you think, C# is better, and C++ has no excuse,
>>>>>>>> code is text, it gets read, tokenized, interpreted and compiled.
This is why C# is written on the top of C++. And this is why C# provides bridges to C++, and makes you able to interact with native C++ modules. This means C# is not universal, and provide possibility to be enriched by help of C++.

>>>>> Much like a macro, when creating a language, you can make the code anything you want, I could write a function:
C++ provides enough flexibility to make abstractions without using macro. Don't start from macro, this is not that you need to become a good C++ programmer. Trust me. I can not prove that, but any C++ programmer will tell you the same.

>>>>> void DoIt();
>>>>> That compiles to an entire game, it's called abstraction, and C++ really needs to learn how to use it.
Yeah, and for each small modification you will need another DoIt
void DoIt1(); will do it, but in red color
void DoIt2(); will do it, but with round movements
So, for each small new requirement in the game you will need other DoIt, but with small difference than the other. After making many DoIts you will see the need of making some extended DoIt, like DoItEx. But after some more time, you will notice that you develop full STL and all your DoIts are part of an archive which you intend to use widely, but will never do it, as you did not do it for long time already.

>>>>> For the record,
For the record, I work as C++ and ASM programmer since 1999. But know them since much earlier.

>>>>> I know various languages x86 ASM(reversing),
I don't want to show my full profile here, because it would take more place than whole text written above. But I only will tell you that I have deep background in diverse technologies, including C#/C++/Java/Perl and many other technologies.
armagedescu 14-Dec-12 6:20am View
   
By the way, I am not sure, but you have to see if there exists any other message loops in the applications.
armagedescu 14-Dec-12 6:09am View
   
Nope. If you send WM_QUIT you do not kill the thread. Sending WM_QUIT does not kill the thread. It causes the GetMessage to return 0 and exit the message loop. So the thread is not killed. It is executed successfully until returning from thread function. If you want to kill a thread, you have to call TerminateThread.
But if the GetMessage freezes, this means there are no messages in message loop. But it is not likely that is freezing inside GetMessage. Try using PickMessage instead, to see more exactly that happens.
armagedescu 7-Dec-12 3:38am View
   
Deleted
Assembly is the language, and everyone programs in Assembly, but not in Assembler. The Assembler is the compiller for that language. Assembler assembles machine language object files from assembly language. And after that object files written in any languages are linked with a linker, into an executable dynamically linked or standalone module.
The assembly language mnemonics are translated each one directly into machine language instruction. So, there is thery little difference. Assembly language is exactly the same machine code, but written in a human readable style. Nothing less and nothing more. And even if some programmer written directly in machine code, that programmer kept jumps in such a way, that is simulating same sintactic sugar from higher language.
If you would have any idea about machine language and assembly you would not say such stupidities. But you are complete null in programming, and of course you have nothing to respond. You have trapped yourself in your own arrogant stupidity and trolling. No one here obligated you to tell such stupidities. Of cource, you have now no way back :)

>>>> Machine code is founded on the equivalents of goto, everything from
>>>> loops, to simple
>>>> "if" statements, and function
>>>> calls, are roughly the same thing as goto.
Yes, exactly, jumps are used to simulate the same conditional, looping, calling statements, which are not provided by ASM but are provided by higher level languages more than 99% of cases. You can verify yourself. Before doing that you have to know that assembly language is. But as I can see you are very likely to fail learning it.

A, yes, as I can see, your last response contains nothing about STL :) You really ran out of any arguments. All the rest is just trolling.
armagedescu 6-Dec-12 10:47am View
   
Deleted
>>>>>No it doesn't, it provides syntactic sugar
ASM programmers uses jumps mostly (99%) for simulating EXACTLY the same syntactic sugar. Moreover, many of ASM programmers uses lots of macros to wrap the jumps to some kind of that syntactic sugar.


>>>>>And I don't need to be an STL expert
Be sure, you are not.

>>>>source.erase(std::remove(source.begin(), source.end(), item), source.end());
std::remove is optimized for fast working directly in memory.

Look at this code, which does not use any vectors, lists, containers, just memory:
///////////////////////
int* z = new int[100];
for( int i = 0; i < 100; i++) *(z + i) = i % 5; //initialization
int* end = std::remove(z, z + 100, 4);
for(int* i = z ; i < end; ) cout<< *i++<< " ";
z = realloc(z, (end-z) * sizeof(int)); // readjust memory
cout<< "--- finish z ---" << endl;


//////////////////
std::remove is just algorithm, and it knows nothing about what is there, memory range, vector, any kind of memory container. This can be a string or anything else. The end operation of vector.erase is just adjusting of the vector size after ending of operation.
You can do lots of std::remove operations, without readjusting the size. And readjust the size only once, only after the end of all removes. While doing lots of operations this is a really big optimization. Can you do this in C#?:
int* z = new int[100];
int* end = z + 100;
for( int i = 0; i < 100; i++) *(z + i) = i % 5;
//lots of changes in memory:
end = std::remove(z, end, 4);
end = std::remove(z, end, 3);
end = std::remove(z, end, 2);
//readjust only once after finishing the whole work:
z = (int*)realloc (z, (end - z) * sizeof(int));
for(int* i = z ; i < end; ) cout<< *i++<< " ";
cout<< "--- finish z ---" << endl;


Yeah, and exactly the same thing, but with vector, fast, robust, and no unneded operations:
std::vector<int> x;
for( int i = 0; i < 100; i++) x.push_back(i % 5);
std::vector<int>::iterator ite = x.end();
//many memory operations
ite = std::remove(x.begin(), ite, 4);
ite = std::remove(x.begin(), ite, 3);
ite = std::remove(x.begin(), ite, 2);
x.erase(ite, x.end()); //readjust only once
for(vector<int>::iterator i = x.begin(); i != x.end(); i++) cout<< *i<< " ";
cout<< endl<< "---- finish vector ----"<< endl;




>>>>#define _VICONT(it) it._Getcont()
>>>>#define _VIPTR(it) (it)._Ptr
These definitions are not for you. They are for STL internal using only, and are used for advanced debugging, when is defined some more advanced debugging level. None of C++ standards for STL provides such a macros to the user. And none of programmers uses these definitions to make their projects. No STL implementations provide them to the end user. Don't focus on C#.

>>>>>I've written several external functions:
O sorry, you've done such a big performance, you've written several function!!! :) Sorry man, but do something smart before talking too much about you've done.

>>>>>This is the reason libraries like Boost exist
Yeah, boost is good, but using it noes not give you so much advantage. This is why many big C++ projects do not use it. Most of C++ applications which have large usage over world, do not use Boost. This is not due to the fact that experienced C++ programmers do not know boost. This is due to the fact that Boost really do not provide such a big advantage. STL is far enough, for people that know it. But for specific tasks as maths, image processing, compression, regular expression, xml processing there exists lots of other libraries. So, STL is not a constraint at all, for people that knows it. It is used everywhere.
armagedescu 6-Dec-12 10:27am View
   
Deleted
>>>>>No it doesn't, it provides syntactic sugar
ASM programmers uses jumps mostly (99%) for simulating EXACTLY the same syntactic sugar. Moreover, many of ASM programmers uses lots of macros to wrap the jumps to some kind of that syntactic sugar.


>>>>>And I don't need to be an STL expert
Be sure, you are not.

>>>>source.erase(std::remove(source.begin(), source.end(), item), source.end());
std::remove is optimized for fast working directly in memory.

Look at this code, which does not use any vectors, lists, containers, just memory:
///////////////////////
int* z = new int[100];
for( int i = 0; i < 100; i++) *(z + i) = i % 5; //initialization
int* end = std::remove(z, z + 100, 4);
for(int* i = z ; i < end; ) cout<< *i++<< " ";
z = realloc(z, (end-z) * sizeof(int)); // readjust memory
cout<< "--- finish z ---" << endl;


//////////////////
std::remove is just algorithm, and it knows nothing about what is there, memory range, vector, any kind of memory container. This can be a string or anything else. The end operation of vector.erase is just adjusting of the vector size after ending of operation.
You can do lots of std::remove operations, without readjusting the size. And readjust the size only once, only after the end of all removes. While doing lots of operations this is a really big optimization. Can you do this in C#?:
int* z = new int[100];
int* end = z + 100;
for( int i = 0; i < 100; i++) *(z + i) = i % 5;
//lots of changes in memory:
end = std::remove(z, end, 4);
end = std::remove(z, end, 3);
end = std::remove(z, end, 2);
//readjust only once after finishing the whole work:
z = (int*)realloc (z, (end - z) * sizeof(int));
for(int* i = z ; i < end; ) cout<< *i++<< " ";
cout<< "--- finish z ---" << endl;


Yeah, and exactly the same thing, but with vector, fast, robust, and no unneded operations:
std::vector<int> x;
for( int i = 0; i < 100; i++) x.push_back(i % 5);
std::vector<int>::iterator ite = x.end();
//many memory operations
ite = std::remove(x.begin(), ite, 4);
ite = std::remove(x.begin(), ite, 3);
ite = std::remove(x.begin(), ite, 2);
x.erase(ite, x.end()); //readjust only once
for(vector<int>::iterator i = x.begin(); i != x.end(); i++) cout<< *i<< " ";
cout<< endl<< "---- finish vector ----"<< endl;




>>>>#define _VICONT(it) it._Getcont()
>>>>#define _VIPTR(it) (it)._Ptr
These definitions are not for you. They are for STL internal using only, and are used for advanced debugging, when is defined some more advanced debugging level. None of C++ standards for STL provides such a macros to the user. And none of programmers uses these definitions to make their projects. No STL implementations provide them to the end user. Don't focus on C#.

>>>>>I've written several external functions:
O sorry, you've done such a big performance, you've written several function!!! :) Sorry man, but do something smart before talking too much about you've done.

>>>>>This is the reason libraries like Boost exist
Yeah, boost is good, but using it noes not give you so much advantage. This is why many big C++ projects do not use it. Most of C++ applications which have large usage over world, do not use Boost. This is not due to the fact that they do not know boost. This is due to the fact that Boost really do not provide such a big advantage. STL is far enough, for people that know it. But for specific tasks as maths, image processing, compression, regular expression, xml processing there exists lots of other libraries. So, STL is not a constraint at all, for people that knows it. It is used everywhere.
armagedescu 6-Dec-12 8:01am View
   
Deleted
What is exactly the value of hres, result returned by CoCreateInstance?
armagedescu 4-Dec-12 7:06am View
   
Deleted
For the vector.erase I do NOT see any problem to solve. Everything work just fine and just neatly, there is NO problem to solve.
Second problem. If you work in C++, please do not think in C#. Working in C++ means thinking in C++, so forget C#. Don't compare with it. Do not try to do C# in C++. Do not translate C++ into C#. Try to find the C++ way with working in C++, and only after that you will feel the power of C++. Yes, C++ is a more capricious language than C#. Yes, it does not forgive mistakes. Yes, it does not keep you away from making mistakes. There is a complete freedom of making mistakes as well as full freedom of making good code. Don't think in macrosses. It is not the right direction to investigate for becoming a good C++ programmer.
Before talking about lacks of STL, you first have to become at least STL competent. But as I see, you are not such an STL expert.
About using goto, you should keep in mind, that you are using C++, not ASM. C++ provides lots of good possibilities for not using goto. ASM does not have them.
And about thinking line. The thinking line of ignoring good advises from lots of experienced people, working in C++ for many years, is the mark of dilettantism.
Anyway, it is up to you, to take good advises in consideration or to ignore them. After getting some more experience, you will understand, will feel that we say, and will find the right way. But this will be very painful process for you with such a ignorance.
armagedescu 30-Nov-12 6:15am View
   
Deleted
I've told already about the need of a map. But you can only map the words. How will you map the sentences and the paragraphs? And there is nothing I've told about the text structure. Even for storing each of them you will need maps, arrays, relations between them, and a lot of spaghetti.
armagedescu 30-Nov-12 5:13am View
   
Deleted
Yeah, and see the paragraphs as well.
armagedescu 30-Nov-12 5:11am View
   
Deleted
Please read attentively, you are very wrong. See "most number of repeated words in each sentence". So, in each sentence, you should store the each distinct word with the repeating count, after that take the maximum one inside the sentence. After that, compare the numbers from each sentence between sentences.
armagedescu 28-Nov-12 5:47am View
   
Is there thrown a EInOutError or EInOutError& ? Or EInOutError* ?
armagedescu 27-Nov-12 12:08pm View
   
search the internet and read the manual before posting any questions
armagedescu 19-Oct-12 11:59am View
   
Of course, it has many things to do with multithreading, and with many other things than multithreading, which can change data at any time, in an uncontrolled by compiler way. Multithreading was just by example, btw a very good example of situations when variables can change in their own way. It can be anything, just keep in mind, port data, socked data, anything which should not be touched or forced by compiller.
armagedescu 19-Oct-12 11:29am View
   
Just keep in mind. It is about volatile, not about InterlockedExchange. Instead of InterlockedExchange you may think about any other function for cross thread data manipulation. Threading functions and objects exists in any OS which supports multithreading.
armagedescu 15-Oct-12 7:25am View
   
Than you, I've given also a vote
armagedescu 28-Sep-12 10:35am View
   
Deleted
In mater of guessing you are right, but technically speaking I answered correctly to the question.
armagedescu 28-Sep-12 6:48am View
   
Deleted
Why not?
armagedescu 26-Sep-12 6:06am View
   
Deleted
Ok, sorry for my bad french, but there is a very useful site: google.com. All you can is to play with button messages, styles and states. You can either call WM_SETFOCUS by SendMessage/SendDlgItemMessage, or call SetFocus. If window handle or dialog item identifier is correct, then the button will draw the focus rect automatically. Any controls which draws focus rect will draw it. You can also call control specific messages, for acheive the same thing, like BN_SETFOCUS, EN_SETFOCUS, HCBT_SETFOCUS, LBN_SETFOCUS and so on. Also see, maybe your button is ownerdraw.
armagedescu 25-Sep-12 10:38am View
   
I agree. This is good article. And there is very well explained the difference.
armagedescu 17-Sep-12 11:03am View
   
ok
armagedescu 17-Sep-12 10:57am View
   
I've already reformated. Anyway, what is the expected result and what is not expected from that you get?
armagedescu 17-Sep-12 10:53am View
   
btw, you may add a overloaded operator << for your point, so you will be able to pass just the point to cout.
armagedescu 17-Sep-12 10:51am View
   
Ok, when you show a code, please format it well. Now, is there a header #included for sqrt function?
armagedescu 17-Sep-12 9:56am View
   
how can you call doModal on a hidden box?
armagedescu 13-Sep-12 5:09am View
   
Deleted
No, you updated one byte, so it is eight bits, not one single.
armagedescu 12-Sep-12 12:12pm View
   
Deleted
I am not sure that I understand your problem. Is it a problem of result calculated, or some other problem? As I understand, you are summing short int by short int. Is it correct? The result returned from checksum is short int and you assign that result to 1 byte integer. So, you lose 8 bits from checksum.
armagedescu 12-Sep-12 11:13am View
   
Deleted
What kind of problem?
armagedescu 12-Sep-12 10:27am View
   
Deleted
Oh no, the < and > where eaten by HTML :)
word16* ptr = reinterpret_cast <word16*> (addr);
armagedescu 12-Sep-12 9:50am View
   
Deleted
You've probably forgotten to request permission for the other instance of the process
armagedescu 21-Aug-12 2:25am View
   
Deleted
I am not sure about the specifics of sqlite, but I think there is no sence to call COMMIT TRANSACTION if you have not executed BEGIN TRANSACTION. And I don't know what are step and reset doing. In normal API for databases, you just call exec on the stmt, and no step, no reset. Any exec of an update/insert/delete statements usualy are transactional. Maybe I am wrong, you have to check more detaily in documentation. I have experience with other APIs, and very little experience with sqlite.
armagedescu 21-Aug-12 2:25am View
   
Deleted
I am not sure about the specifics of sqlite, but I think there is no sence to call COMMIT TRANSACTION if you have not executed BEGIN TRANSACTION. And I don't know what are step and reset doing. In normal API for databases, you just call exec on the stmt, and no step, no reset. Any exec of an update/insert/delete statements usualy are transactional. Maybe I am wrong, you have to check more detaily in documentation. I have experience with other APIs, and very little experience with sqlite.
armagedescu 14-Aug-12 7:13am View
   
Deleted
Anyway, I don't see there the cause of crash. If the problem is in library loading precedence, then load your dll explicitly with LoadLibrary, and there will be no problem with DllMain. But if OCIInitialize loads other dll, then you probably have no choice. In fact this is why DllMain exist. For initialization. All depends on how your dll is used.
armagedescu 13-Aug-12 7:40am View
   
Deleted
I don't believe there is such a restriction. If there is such a restriction, could you point exactly to official documentation from Oracle where it is?
armagedescu 8-Aug-12 17:12pm View
   
Deleted
Yep, just ask.
armagedescu 8-Aug-12 4:07am View
   
Deleted
If application is CPU intensive, this means something goes wrong. Do you see, in the query a search condition, where tag=?. I guess the tag column is not idexed. Try to create a index on tag column, and the query will execute much faster. And please make the variable name more informative. Instead of statement use selectTagsStmt. Instead of stmt use updateTagValuesStmt. Making a more informative name means to make the program more informative, understandable and maintainable. And making a longer name does not affect the program performance.
armagedescu 7-Aug-12 15:16pm View
   
So, yes, you have to create an instance of exposed object. You can not expose a function from an a class of objects. It must be instanciated.
armagedescu 7-Aug-12 3:04am View
   
Deleted
Ok, you have to move the bind and char* outside the for loop. You have to bind the parameter only once, execute once, and interate with for loop. Also I don't understand why you use resed inside for. It have to be before or after for loop.
armagedescu 3-Aug-12 12:20pm View
   
Deleted
Ok, I understand. First of all don't mix C stdio with C++ iostream. I see that you are closing file before reading from it. btw, you can use GetFileSize function from WinAPI. Other thing is that you send size. And you try to read 128 bytes from the client. For instance size is 3 digits, the rest 125 are the content of the file.
The last thing is that you use sendto/recvfrom. Why you don't use just send/recv?
armagedescu 3-Aug-12 11:48am View
   
Deleted
See more information on functions sqlite3_bind_parameter*. Look for info on parametrized queries, or binding values to prepared statement. Parameters are either identified by index, or by name. See how to compile/prepare statements, how to use parameters, to bind them, so on.
Hope this info will help: http://www.sqlite.org/capi3ref.html#sqlite3_bind_blob
armagedescu 3-Aug-12 8:42am View
   
Deleted
ASSERT_VALID will break the execution only if the expression inside is invalid. Anyway, if you build in debug mode, then even invalid expression will not break execution. I suppose you need to look inside ASSERT_VALID, and also look at build mode, debug/release. ASSERT_VALID calls a member function from the provided expression.
armagedescu 2-Aug-12 8:22am View
   
If function does not get called, then there is other problem. If the signature is wrong, then function usually get called, but it crashes at runtime. But if it does not get called, then problem is elsewhere. The dll have to declare function with __declspec(dllexport) but application which loads the dll have to declare it as __declspec(dllimport).
Anyway, try to debug and see if dll is still loaded when you want to call the function, and what exactly is called when you call the function. Try to debug in disassembly, and see what happens after ASM call is instruction is executed. You also can open memory window and enter the address of function.
In many times GetProcAddress can get the address of a jmp instruction. In that case you have to see where this it jumps, what is on the memory.
armagedescu 2-Aug-12 6:12am View
   
Deleted
If ASSERT_VALID fails, then expression inside is invalid. So, check why is it invalid.
armagedescu 1-Aug-12 7:30am View
   
Strictly responce is no. This is because in fact VB function CreateObject calls COM API functions CLSIDFromProgID and CoCreateInstance. CoCreateInstance inside calls CoGetClassObject and IClassFactory::CreateInstance. None of these functions provides information about the caller.
But you may try to investigate if there is any COM registration information which can limit the usage of COM object. In fact there is a strictly limiting possibility if you use Reg Free COM (also named "side by side"). Anyway, if you limit the usage of component, the active script itself is not restricted, and will expose any functionality to external programs.
armagedescu 1-Aug-12 7:19am View
   
I suppose somewhere is used isQueue, but is not exposed. Or it is exposed, but you are not using correct libs or references. You have to find the place where it is used, and see, if it is a COM object, then you have to add reference, and remove the lib which was meant to add this function. But if it is lib function, then you have to add the lib.
armagedescu 30-Jul-12 7:22am View
   
:)
armagedescu 30-Jul-12 7:06am View
   
If you know how to create console application, then you have the response to half of your question.
You need to google for the same question, but omit win32 console. And yes, you have to read that you google, and understand it, before posting questions here.
armagedescu 30-Jul-12 6:59am View
   
You are learning not only the theory, but you are learning programming as well. Don't expect someone else to write your homework.
armagedescu 30-Jul-12 6:52am View
   
In fact as you may see, in the InProcServer32 is registered a dll, which acts instead of your script component. This dll uses your script, registered in ScripletURL.
armagedescu 30-Jul-12 6:38am View
   
Threading model is Apartment. For more info you may check the registration information with OleView, coming with VisualC++, or look in the registry under key
HKCU\CLSID\{GuidOfYourComponent}
armagedescu 23-Jul-12 9:57am View
   
Deleted
I had a huge project on which the above model would be a nightmare. Imagine a project with 20 thirdparties, each of them having lots of dll files. Thirdparties were very dinamically changing by third party developers. And consider adding each dll, add custom build tools, and so on. Or remove them permanently. But just a batch file, for each thirdparty, provided by the thirdparty developers was enough. No need to change the solution. No problem to inherit any needed property from the project by the same command line used for the dll.
The program itself has more than 350 projects in solution, beside the thirdparties.
armagedescu 23-Jul-12 8:55am View
   
Deleted
But is easier to create an one single batch (bat/cmd) file and to add anything there. Add it to the project, associate the custom build command line to FullPath of the cmd file, and no more things to do.
armagedescu 23-Jul-12 5:57am View
   
Deleted
Just build is very enough.
armagedescu 23-Jul-12 5:56am View
   
Deleted
Using just build with custom build tool is just a snap. No need to do workarounds.
armagedescu 23-Jul-12 4:12am View
   
There is no build, then there is no sense to add post build. And even less sense to add fake build.
If there is needed just command execution, then there is no problem just to add command (cmd or bat) files to be built. After that you only have to change property to custom built tool and set the command to the cmd path itself $(FullPath). Then OS will simply run them.
armagedescu 23-Jul-12 4:08am View
   
Deleted
Post Build work if there is a successful build. But if there is nothing to build, then in might be likely not possible to get post build event executed.
armagedescu 23-Jul-12 4:06am View
   
Deleted
You could do that much simplier. No need to change standard behavior of build events. And no need to add pre/post build events. If you need build only to execute batch commands, then you just have to create batch files and to associate them to themselves as custom tools, to be executed by OS.
armagedescu 19-Jul-12 10:10am View
   
Deleted
You should define your structure at RPC level. This means to define it in RPC language, such as some kind of IDL, or other one, depending on your platform. After that you have to compile this one with provided compilers. These compillers will make C++ code, which you will use. If you use Windows RPC, then you will write your procedures in IDL and will compile with MIDL. Anyway, provide some more info about your system, compiler, kind of RPC, snippets of code.
armagedescu 18-Jul-12 10:48am View
   
Deleted
No. Not only sizeoff. If you need just within same HDD exchange, then you don't need RPC at all. Anyway, doing RPC you have to think RPC.
Consider a point
struct point{int x; int y;};
Consider two systems, big endiang(BE) and little endian(LE). Structure will have different binary representation.
The method void setPoint(const point) pass an rpcpoint, but each program two systems will have just point, with different binary representation.
Suppose you want to add one more dimension to your point, make it relativistic, and add the double time.
struct point{int x; int y;double time;};
Compiller generates marshalling for bigger point, with three attributes, the proxy code marshalls now the x, the y, and the z, and the stub code does the unmarshall for the same thing. So, server program pass a point to RPC and RPC does something. After that RPC does some other thing and pass it to client as a point.
All the code generated by RPC compiller is the RPC level, so you don't really have to carry about it.
armagedescu 18-Jul-12 10:15am View
   
Deleted
But the question is about RPC. RPC exists in many places where is no Windows and no COM.
armagedescu 18-Jul-12 10:13am View
   
Deleted
Look at your link above again, and just think, that you have to implement in, out, reimplement again when changing the structure, and so on, чзж. Moreover you have to do it via one more layer, the COM. Much easier is pass marshalled memory buffer directly to RPC, as the IStream will solve exactly nothing in this case. IStream interface exists for COM objects and formats. While there is no COM, there is absolutely no reason to use IStream.
If user wants to pass a structure via RPC, the answer is to make it RPC. Any changes of the structure just recompile the RPC definition and recompile the program.
armagedescu 18-Jul-12 9:43am View
   
It is unstructured, and it deppends on the implementation. Object serializes itself in an RPC unaware way. in/out has no warranty on correctness of transfer. For instance consider in/out on whole structure memory buffer at once.
Seralizing and marshalling make very different things, this is why they exists separated to each other.
armagedescu 18-Jul-12 9:37am View
   
Deleted
Anyway. IStream is COM interface. This most likely first means that you will have to initialize COM, because RPC does not have COM interfaces and type libraries built in.
armagedescu 18-Jul-12 9:27am View
   
Deleted
It is about IStream pointer, not about the Stream managed by IStream. This means marshalling pIstream to pIstream. This means after you unmarshall the pIStream you will be able to access the stream. But the stream itself remains the same unstructured buffer, on both, client and server. And marshaller knows nothing about how should be used an unstructured buffer.
armagedescu 17-Jul-12 6:53am View
   
Ok, I've just compiled this with GCC 4.4.0
/*x.c*/
void main(int a, void* b, double* c, char d)
{
printf( "hello word from not C\n");
}
G++ detects exactly the void main, and nothing in the parameter list :D. So if you change void to int, everything works. Only have to include stdio.h and return a value.
Anyway, if you write a program which is not portable, it is not a problem while you don't care about portability.
armagedescu 17-Jul-12 6:40am View
   
In my first reply I've told that I agree that it should be avoided, and STOP ON ARGUING ABOUT "should be avoided or not". I've already told, should be. Now I just explain why it works, no matter of compiler, and why it is not as big problem as it is intended to pretend. It is C call to your main function, this is why it works. No matter that C compiler you use. Most people which say that it is bad habit. And they try to scary you with explanation which denotes lack of C knowledge.
armagedescu 17-Jul-12 5:51am View
   
As I said, it is just holly war. Is permissible everything the language admits and is not constrained by the language. Everything else, like "is recommended" or "is not recommended" is just a convention. Any thing that should be prohibited, is prohibited (by the language), and you can not use. All the rest is just holly wars.
armagedescu 17-Jul-12 3:26am View
   
It was C. No one intends to add backward compatibility for void main. And it was never introduced by microsoft. It was always working like this. In standard C you can make such a program "main(){}", no prototype, by default assumed int, no return. And this is a fully valid C program. So, you can write "void main(){}" there is no conflicts, because this is the way C works. You can just use void instead of int if you don't care about return value. Not recommended, but you can do it. Nothing to do with standards and supports. C just works like this.

See such a program, you even are not obligated to declare the functions before using.
See mixing the return type, and returning nothing in int function.
/*main.c*/
int doX()
void doy(){printf("hello world\n");}
main(){doX();}
/*externaltest.c*/
int doy()
void doX(){doy();}

The program is fully valid under any C compiler.
Moreover. I can add some more hollywar. For example in C you can do like this
void main(int a, int b, int c){ do something }
And it fully works, however the parameters are useless.
armagedescu 16-Jul-12 15:40pm View
   
Oh noo, holly wars again. No one intended to add any exception. And in Microsoft documentation is no reference to void main. It is mostly a side effect of how C language works. Function main is C function. And in C you are not obligated even to declare the type of returned value. But if you declare some return type, you are not obligated to return anything. This is why it works, and just no one cares about void main, excepting holly wars.
armagedescu 16-Jul-12 12:07pm View
   
I only agree that it is not standard and have to be avoided. But if you use it, not a big deal.
I don't agree that "it may work". It works. Not for me. It just works :) In some discussions in the internet is said that it might crash because copy/paste "could lead to stack corruption in the program's exit sequence", and is followed by a code which is meant to demonstrate how it can corrupt the stack :). But exactly that copy/paste code from disassembler proves that it has absolutely no impact on the stack :D. Return value of C integer has no impact on the stack, no matter how many times you return. The return value is returned to the system as exit code. So, if you don't care about exit code, then no problem. Even in void main you can return needed exit code with void exit(int) function.
armagedescu 16-Jul-12 10:39am View
   
Deleted
How is this related to C++?
armagedescu 16-Jul-12 10:29am View
   
I don't see how this is related to C++
armagedescu 13-Jul-12 10:17am View
   
Deleted
First of all, you should complete the task of counting occurrences of all words in the sentence. Just as I've described above. After that, use iterators to iterate each element of the map to compare values and find the max one. The corresponding key is the word you search.
armagedescu 13-Jul-12 10:16am View
   
Deleted
First of all, you should complete the task of counting occurrences of all words in the sentence. Just as I've described above. After that, use iterators to iterate each element of the map to compare values and find the max one. The corresponding key is the word you search.
armagedescu 13-Jul-12 4:32am View
   
Don't worry, it works. You can make graphs just inside the Performance Monitor.
armagedescu 12-Jul-12 7:18am View
   
Deleted
And the vice versa problem. You very closely clean the memory, to avoid leaks. You release a thirdparty object and your pointers passed to that object. The third party asynchronously using a pointer to your clases. So, internally your thirdparty while releasing has yet to make something of your pointers. Some of them are already deleted in your application. Shared pointers is not the answer here, because is a thirdparty not supporting this. You will face a crash, and you even will not know what is the thirdparty trying to do, because the target of the pointer is no more existing. Just facing a deleted memory and try to guess who allocated it and who deleted it, without sources to thirdparty. Only you see it is a callstack. In a small application is simpler to detect even these situations, but not simple to fix. In big applications sometime is very complicate to diagnosticate these situations, even if there is an easy to fix to apply.
armagedescu 12-Jul-12 7:03am View
   
Deleted
Taking in consideration your good intention, I've changed the poits.
In big applications, leaks exists, even if you are following best C++ memory management practices. Detecting just a leak some time is easy, sometimes is difficult. But detecting the leak which escaped all these practices is much more difficult. Just imagine all the forest of different kind of autopointers which can do nothing because of some ciclic deppendence. And this is impossible to escape. You just will face it.
About third party library. In big applications you will use lots of third party libraries. So, to your leaks will be added leaks escaped from third parties, or leaks of miss using them. Even such components as Internet Explorer will generate lots of problems with memory leaking.
In an application, different allocations happens everywhere. So you will have to face very big logs, even memory diff will be very big. And you will have to analyze the logs to find exactly the memory leaks.
armagedescu 11-Jul-12 17:37pm View
   
Ok, it was me.
In fact, memory leak detection is not a trivial task. It is already in the application, and you have to find it. If a big program leaks, then it impossible to diagnose it just by analyzing the code. Moreover, sometimes is even impossible to know if what we face is a memory leak, or just memory consumption problems. Sometimes you even do not have the sources, but you have to detect the memory leaks with full callstacks, then assign them to development teams to fix. In development environment usually memory usage is much smaller than in real life. In most cases you will not be able to deploy all the development environment to debug at user site.

Speaking in terms of inaccuracies, it is about memory leak detection, not about memory leak avoiding or about best programming practices.
armagedescu 11-Jul-12 17:07pm View
   
Deleted
:)
armagedescu 11-Jul-12 17:06pm View
   
Here is a very good and detailed help file from Microsoft
http://www.microsoft.com/en-us/download/details.aspx?id=2764
Download it and use. If you can not read it, then you should right click the file, open the properties and press unblock.
In the contents Tab you will see script components. There is everything you need.
armagedescu 10-Jul-12 2:00am View
   
As I already told in the first reply, you have to write script components. They are not wrappers, they are components. Read about script components. This is the only way to extend the scripts. For instance VBScript regular expression is plain ActiveX, and you may use it outside the script anywhere you like.
They are XML files, with .wsc extensions. Inside that files you put your code. After that register extension with regsvr32 and it will be accessible from any application, script, C++, VBA, JScript, C#. You instantiate them as COM objects, with CreateObject inside VBS, CoCreateInstance in C++, new ActiveXObject in jscript and so on. You can write ActiveX components components in any language you like.
armagedescu 10-Jul-12 1:45am View
   
Try using DWM
http://msdn.microsoft.com/en-us/library/ff468822(v=vs.85)
armagedescu 9-Jul-12 16:52pm View
   
Deleted
In some generic case using english format is ok. But in a heterogeneous environment, when you bind dates to some external variables, this is not the answer. And this is definitely not the answer in a nonenglish environment.
Using like function makes string bypattern comparison, so it converts both, right and left operands to string. In fact when working with dates you have to avoid as much as possible string comparisons. To make a date from a string use Format function, with specifying the exactly provided format. To compare a day date to a day date, you should use datepart/datediff. In MS Access SQL you may use VBA functions. Both, builtin and your own. See documentation on VBA datetime functions.
armagedescu 9-Jul-12 11:23am View
   
You also can do it the way round. From VBScript2 call some ApplicationX function meant to get the Script1IDispatch. All you have to know, is that an IDispatch from VBScript point of view is an object, with functions, methods, properties, nothing more.
armagedescu 9-Jul-12 11:19am View
   
Ok.
Suppose, you have ApplicationX which is using (hosting) two scripts, VBScript1 and VBScript2.
So far everything is good. ApplicationX has the script dispatch do script1 and script dispatch to script2, let's call them Script1IDispatch and Script2IDispatch.
VBScript1 can not call functions from VBScript2. But VBScript1 can call functions from ApplicationX and VBScript2 also can call functions from ApplicationX. And viceversa, ApplicationX can call functions from VBScript1 and from VBScript2.
Any VBScript object is just an IDispatch. So, you need to initialize a script object inside the VBScript2. Supposing you have the variable SomeVBScript2Variable, which is meant to refer VBScript1. All you have to remember, is that any objects are just IDispatch. In this case, you initialize a VBScript2 variable to Script1IDispatch.
In pseudocode it would look like this:
Script2IDispatch->SomeVBScript2Variable = Script1IDispatch.
In real code this means to call GetIDsOfNames for "SomeVBScript2Variable" and to call Invoke with a pointer to Script1IDispatch.
After that you can call from VBScript2 SomeVBScript2Variable.SomeScript2Method...
armagedescu 9-Jul-12 9:50am View
   
Deleted
You don't need to assume all of this. SQLite has different compilation options for each assumption case. Just compile it according to needs of your limitless sistem
http://www.sqlite.org/compile.html
http://www.sqlite.org/custombuild.html
armagedescu 9-Jul-12 8:45am View
   
It is member variable and private.
armagedescu 9-Jul-12 8:38am View
   
Deleted
Lots insertion/deletion is like lots insertion/deletion of engine and wheels on a fully loaded lorry you are driving at the moment, without stopping it. This kind of application need special approach. I am quite sure this is not the case here.
armagedescu 5-Jul-12 8:11am View
   
Deleted
Hope appearing of old questions in top is not a good reason for downvoting wars.
armagedescu 5-Jul-12 8:09am View
   
It was actually in the top when people responded. It is not a problem to ignore a question for people who is not interested in it. I am not addicted to newest questions. I've only seen it and posted the answer. It is a valid rule for any forum, no one can prohibit others to answer questions.
armagedescu 4-Jul-12 5:15am View
   
Sometimes messages are still in the queue, but there are other higher priority messages. So, sometimes it might never get processed. In this case need to call PeekMessage to take your message. And processing of WM_PAINT is not the place to generate other WM_PAINT. WM_PAINT must only reflect current data or state change. For instance frame changed, or recover of picture after being covered by other window. Logically this message itself must not generate other WM_PAINT.
Updating video in the frame is a timed process, which have to be linked to WM_TIME. Here you have to compute the image, not in WM_PAINT. After that you can notify window to repaint.
armagedescu 27-Apr-12 4:42am View
   
Reason for my vote of 1
lame question on interview
armagedescu 26-Apr-12 11:04am View
   
The key is not to do InvalidateRect/UpdateWindow on WM_PAINT. On WM_PAINT you only have to paint current img/bitmap in the window, nothing more. But updating the image have to be done on some kind of WM_TIME'd manner. After ending of updating current frame of video content and call InvalidateRect/UpdateWindow. As result you will handle WM_PAINT and will update the window contend with the image/bitmap of current video frame.
armagedescu 26-Apr-12 9:09am View
   
And yes, you may call directly UpdateWindow, without InvalidateRect. WM_PAINT most likely to be passed. But you may still need InvalidateRect if you use painting PAINTSTRUCT from the BeginPaint.
armagedescu 26-Apr-12 9:03am View
   
When in program something happened, and window have to be updated you need to call InvalidateRect. You may pass FALSE to erase, to avoid flickering. And call UpdateWindow in order to have WM_PAINT message passed.
armagedescu 26-Apr-12 7:57am View
   
Reason for my vote of 1
Seems like a lazy student doing the lab