the code shows std::bad_alloc error dont know what to do about it when remove the push_back it dissapears. please help on what to do. this happens only when I am entering a huge string s else it runs perfectly fine. is there another efficient way to find all the possible substring, arrange them lexicographicaly and then concatinate them back into one string????pls help thnx in advance
1. Always post the code that you actually use and that shows the described (problematic) behaviour
2. Cleaning up your code can occasionally help, but if you do so, then (a) make sure the clean code still compiles (and runs) to the extent the original code did, and (b) make sure the code still shows the same issue(s)! There really is no point discussing code that doesn't show the behaviour you are describing.
3. Learn to use a debugger, step through your code, and examine the current value of your local variables. Since you already know where you're crashing, it's a good starting point to set a break point before the call to push_back(), and investigate the state of your variables then.
Bonus tip: remove that line using namespace std; It is a crutch and will make it more difficult to spot issues in your code. You'll need to add the prefix std:: in many places, so that requires additional typing, but it really isn't that hard, and it adds to the readability of your code as well as reducing the likelyhood that you're mixing up local and library symbols! The extra effort of always typing std:: pays off very quickly!
Using-directive does not add any names to the declarative region in which it appears (unlike the using-declaration), and thus does not prevent identical names from being declared.
The using-directive using namespace std; at any namespace scope introduces every name from the namespace std into the global namespace (since the global namespace is the nearest namespace that contains both std and any user-declared namespace), which may lead to undesirable name collisions. This, and other using directives are generally considered bad practice at file scope of a header file.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
It's been a long time since I developed a program.
Now I need to build a simple register program that needs to be a standalone exe running on Windows 7 and above.
Is this possible? if yes where do I start?
I want to use (and learn) Visual C++ in the process.
that really depends on what you mean by 'standalone' - I'll assume unless otherwise corrected you mean as in 'not connected to a remote database ie on another machine in a network' .. in which case, yes, very possible - there are versions of MSSQL that are light enough, there's SQLite and plenty of other databases you can deploy with your application for a 'standalone' install - the decider between databases is/are the usual questions concerning databases
how ? make google your friend - read voraciously - trawl CP for example projects - find an example that you 'grok' and use it as a model for your own case - the only way to learn is to do.
When you have specific issues, there are forums here you can post technical issues on
Hey everyone i am working on an old code which was written for 'Xtion pro live RGBD camera' my task is to make it compatible for kinect v2, i.e. it must take the input form kinect v2 instead of the old camera. Can somebody help me in the regard that which part of the code to be changed and any idea how to do that?(Working with c++ in visual studio 2013 (The old code includes Opencv, OpenNI and NiTE linked to it)).
(As far as i understood i have to change only the part of code where image acquisition is happening but its too complicated for me as i am new with it)
Hey everyone i am working on a code where i have to detect angles between the 3 joints i.e. Hip,Knee and ankle, would be grateful if someone here can help me out.(I am working with c++ in Visual studio 2013(The old code includes Opencv, OpenNI and NiTE in it)).
I am inserting text to CListCtrl Items with function
SetItemText(). The text contains '\t'. I would need to display the text of the subitems with expanded tabulators.
Is there a way? I cannot find any hints about this issue.
you propose to replace with number of tabs?
it's much effort, because I need to loop over the text and replace by different number of tabs (depending on position).
further this works only for fix size fonts.
Well the issue is quite simple: if the control does not expand them for you, then you will need to do it yourself. You can use the GetTextExtentPoint32 function[^] to calculate the average size of the characters, and use that information to calculate the width of the tabs.
hmm, maybe I do not understand this approach completely!
I could calculate the text size and tab position. but when replacing the tab character with a number of blanks, I will not get an accurate tab position. it will looks quite crude over several lines. further I will have additional issues with the blanks, when I want do make in place edititing.
Is there any possibility to draw the text of an subitem by myself? e.g. if I would catch a notification message that an subitem needs to be drawn, that I call a function like CDC::TabbedTextOut() ?
Last Visit: 24-Oct-20 9:04 Last Update: 24-Oct-20 9:04