|
I can't open the OpenSCManager Function in C++ & Debug.
The error-code is always 5.
It works, when i don't use Debug with Admin-Rights only.
With VS 2008 it works.
What can i do ? 
|
|
|
|
|
The code that attempts to use this function must have admin rights.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
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
#include <cmath>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include<string>
#include <algorithm>
using namespace std;
bool sortByString(string &t1, string &t2)
{
return t1 < t2;
}
int main() {
string s,sub,i,c,q;
int T;
cin>>T;
while(T--){
cin >> s;
int length = s.length();
cin>>q;
vector<string> ss;
for (c = 0; c < length; c++)
{
for (i =length-c;i>=1; i--)
{
ss.push_back(s.substr(c,i));
}
}
s="";
set<string> se(ss.begin(),ss.end());
ss.assign(se.begin(),se.end());
vector<string>::iterator p;
for( p=ss.begin();p!=ss.end();++p)
s.append(*p);
cout<<s[q-1]<<endl;
}
return 0;
}
|
|
|
|
|
I wonder how your code could possibly compile (in fact, it doesn't on my system, using g++ ): you are using the variable c , declared std::string where a int is expected.
|
|
|
|
|
sry c and i are integer types. I was making it look proper. in the begining they were all in different places
|
|
|
|
|
If you want proper help then you have to post the original code.
|
|
|
|
|
q is defined as a string , yet you are using it as a subscript in the following:
cout << s[q-1] << endl;
Please clean up this code if you are really expecting help from us.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
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!
If you don't believe me, the warnings are all over the place right in the C++ reference. See for example http://en.cppreference.com/w/cpp/language/namespace#Using-directives[^]:
cppreference.com wrote: 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.
and
cppreference.com wrote: 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.
Emphasis mine.
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)
|
|
|
|
|
Nice to meet you guys,
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.
My best regards,
Rodolfo
|
|
|
|
|
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
|
|
|
|
|
Garth J Lancaster wrote: the only way to learn is to do. Agreed!
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Member 12129820 wrote: Now I need to build a simple register program...
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
|
Thanks guys for the help.
|
|
|
|
|
Would it be possible to code the sound to text software from c++? what should we use for that?
|
|
|
|
|
|
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)
modified 7-Nov-15 19:07pm.
|
|
|
|
|
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)).
modified 7-Nov-15 18:49pm.
|
|
|
|
|
Hi all,
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.
Many Thanks
modified 8-Nov-15 15:31pm.
|
|
|
|
|
You need to expand the tabs yourself before adding the strings to the control.
|
|
|
|
|
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() ?
Thanks again!
|
|
|
|
|
|
Member 8534035 wrote:
I am inserting text to CListCtrl Items with function
SetItemText(). What does the call to SetItemText() look like?
Member 8534035 wrote: The text contains 't\'. What is so special about the letter t followed by a backslash?
Member 8534035 wrote: I would need to display the text of the subitems with expanded tabulators. What in the world does this mean?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|