|
Ok, this might be a solution. Use a std::vector<std::vector<std::string> > > ,which can easily grow on demand. To maintain the 2d array interface, wrap the thing into a class that provides the indexing feature:
class twodstringarray
{
std::vector<std::vector<std::string> > > data;
public:
std::string& operator()(size_t x,size_t y)
{
while(x>=data.size())data.push_back(std::vector<std::string>());
while(y>=data[x].size())data[x].push_back(""):
return data[x][y];
}
};
...
twodstringarray array;
array(100,10)="hello";
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
I tried to capture a WM_MOVING in a CDiaologBar subclass of mine to make it snap to the borders when in floating state.
But apparently ,if my DialogBar is floating, another Miniframe is built around my DialogBar. (or something like that)
How can I delegate the WM_MOVING message from this MiniFrame to DialogBar
without having to start all over again ? (because I really cannot afford the time)
Any help will be much appreciated.
I used to have a life ... now I have a computer
|
|
|
|
|
Hey gus I currently working on a project which change an math expression into a binary tree. But it seems that a stack problem has raised probably because of the stack. I tried to solved the problem but failed. Could someone do me a favor? Thanks!
//Source
#include <ctype.h>
#include <stdlib.h>
#include <stack>
#include <iostream.h>
#include <string>
struct Node
{
char* key;
Node* left;
Node* right;
};
bool ischar(char);
void calculate();
void evaluate(char*);
void inorder(Node*);
std::stack<char> stackOperator;
std::stack<node*> stackOperand;
void main()
{
char infix[50];
Node* node;
cout << "Expression: ";
cin >> infix;
evaluate(infix);
node = stackOperand.top();
cout << "print" << endl;
inorder(stackOperand.top());
}
bool ischar(char ch)
{
return isalpha(ch) || isdigit(ch) || ch == '.';
}
void calculate()
{
//Create a node combined with left and right trees
char op;
Node* temp;
Node* left;
Node* right;
op = stackOperator.top();
stackOperator.pop();
right = stackOperand.top();
cout << "r add: " << right << endl;
stackOperand.pop();
left = stackOperand.top();
cout << "l add: " << left << endl;
stackOperand.pop();
temp = (Node*) malloc(sizeof(Node));
temp->key = &op;
temp->left = left;
temp->right = right;
stackOperand.push(temp);
}
void evaluate(char* infix)
{
int sign = 1, decimal, length;
char variable[20];
bool readyForUnaryOperator = true;
Node* temp;
stackOperator.push('(');
while(*infix != '\0')
{
cout << *infix << endl;
while(isspace(*infix)) infix++;
if(ischar(*infix))
{
//Get number or variable
length = 0;
do
{
variable[length++] = *infix;
infix++;
}
while (ischar(*infix));
variable[length] = '\0';
temp = (Node*) malloc(sizeof(Node)); temp->key = ecvt(atof(variable), strlen(variable), &decimal, &sign);
cout << "variable: " << temp->key << endl;
temp->left = NULL;
temp->right = NULL;
stackOperand.push(temp);
cout << "VAR " << variable << endl;
sign = 1;
readyForUnaryOperator = false;
infix--;
}
else if(*infix == '(')
{
stackOperator.push('(');
readyForUnaryOperator = true;
}
else if(*infix == ')')
{
while(stackOperator.top() != '(')
{
cout << stackOperator.top() << endl;
calculate();
}
stackOperator.pop();
readyForUnaryOperator = false;
}
else if(*infix == '*' || *infix == '/')
{
if(stackOperator.top() == '*' || stackOperator.top() == '/')
calculate();
stackOperator.push(*infix);
readyForUnaryOperator = true;
}
else
{
if(readyForUnaryOperator)
{
if(*infix == '-') sign = -sign;
}
else
{
if(stackOperator.top() != '(')
calculate();
stackOperator.push(*infix);
}
readyForUnaryOperator = true;
}
infix++;
}
while(stackOperator.top() != '(')
calculate();
}
void inorder(Node* root)
{
//Print the tree in inorder form
if(root == NULL)
{
return;
}
inorder(root->left);
cout << *(root->key) << endl;
inorder(root->right);
}
|
|
|
|
|
geeee ... Do remember these pages are html, so watch the < and > (which are written & g t and & l t without spaces) in the includes, and always post a code between <pre> and </pre>. You´ll get 50% more chances to get an answer quickly
~RaGE();
|
|
|
|
|
Innomino wrote:
But it seems that a stack problem has raised probably because of the stack
Lol ... well guessed ... I´ve tried to look into your code, but ... Could you be more specific ? Does your app crash ? When exactly ? Which line in the code you´ve posted ?
~RaGE();
|
|
|
|
|
Hi everyone,
I'm having troubles with some "simple" activeX programming. I'm using MSVC .NET and set up a project as "Simple ATL Control" with a class of "Simple Object". I'm trying to pass a string to this exposed method from java-script or VBScript. Everytime I try to see what the string they passed was, I get only the first char of the string and nothing more. I think I've tried just about everything (except the right thing, obviously). Here's the code :
[source]
// IDL bs
[id(1), helpstring("method ClientWrite")] HRESULT ClientWrite([in] VARIANT report_name, [out,retval] BYTE * bSuccess);
// Later in the same header file
STDMETHOD(ClientWrite)(VARIANT report_name, BYTE * bSuccess);
// Implementation
STDMETHODIMP CATS::ClientWrite(VARIANT report_name, BYTE * bSuccess){
::MessageBox(NULL, (LPCSTR)report_name.bstrVal, (char *) report_name.byref, MB_OK);
return S_OK;
}
[/source]
Why only 1 char? The implemenation code looks a little not uniformed cause I've been messing with it trying to get it to work. Any help is appreciated. Thanks.
|
|
|
|
|
FREAKIN' UNICODE!!!!! BSTR is 16-bits wide....... I suck!
Refernce :
::MessageBoxExW(NULL, report_name, report_name, MB_OK, NULL);
works.
|
|
|
|
|
Hello all, I am having a bit of a problem with databases. Right now I have an application that stores data into an access database. But when the database goes over 2 gigs the application crashes out and it starts over writting the header file. Please give me some suggestions with using other database collectors, that would be a great help. Thanks
|
|
|
|
|
Yes, that's correct, because maximum size of the Access database is 2 gigabytes minus the space needed for system objects. Switch to MS SQL Server.
|
|
|
|
|
Martin,
I do not want it to reside on a server i need it to be independant.
|
|
|
|
|
OK, but you will not get more than 2G data into the Access database. MSDE could be a solution for you, however, check the limits first. I do not know it, I tried MSDE once and it was not good enough for me (it does not support multiple user access very well).
|
|
|
|
|
Martin Ziacek wrote:
Switch to MS SQL Server.
Why would one out of free will pay quite a lot of money for something that is also available freely?
If you need an SQL server, maybe Firebird could be something to have a look at.
|
|
|
|
|
Mike Nordell wrote:
maybe Firebird could be something
Well, maybe, at least it has got well documented bugs like ORDER BY has no effect. But, frankly, I am not interested in discussion about better or worse products. If you dislike MS SQL Server, do not use it and recommend something else, and obviously you have to know why you do that. I suggested MS SQL Server, because e.g. it supports import of the MS Access database. Is there the same feature in Firebird? I guess there is no such a thing. And what would be the cost of the development and maintenance of the database with Firebird? You have to understand that there are more requirements than just price of a piece of software.
|
|
|
|
|
What OS ? Windows 95/98 have a 2 gig file limit AFAIK.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
Jamie,
The OS is both Win 98 and Win 2000. I need to find the optimal database application that does not reside on a server and is independat like Access. Do you know of any out there?
|
|
|
|
|
|
Have a look at MSDE, Microsoft's cut down version of SQL Server 2000. I'm not sure on it's maximum specs but it is a lot cheaper than investing in the full version SQL Server.
You'll find details about it on the Microsoft web-site.
Michael
Look, try and use your intelligence, man, even if you are a politician. - The Doctor
|
|
|
|
|
MSDE is limited to 2GB too. clickety
Is mysql an option?
bibamus, edamus, cras moriemur [eat, drink, for tomorrow we die]
|
|
|
|
|
As far as stand-alone databases MS Access is probably you're best bet. Unfortunantely, there is a 2gb limit.
One idea: split the DB into multiple MDB files and LINK the tables into a master database. Basically with this configuration you can still have a single view of the DB but have the data from the various tables spread out. This will not work, though, if you have 1 table that exceeds your 2gb limit.
Another idea: most access databases are not designed well (I'm not saying yours is poorly designed, just that this is what i've seen.) You should look at the size of the columns in your tables and see if they can be shrunk. Many DB's I've seen use the default size for text columns which is 50 characters. Often this leaves alot of unused space. Also, look for redundant data and consider normalizing the database a little. (Normalizing has the unfortunante side effect of causing you to modify your code, though.)
|
|
|
|
|
In Platform SDK of MSDN, about PeekMessage function: it says we can use PM_QS_PAINT or some other values to specify that only certain message should be processed. But when I use this value, I got complie error:'PM_QS_PAINT' : undeclared identifier. I'm sure I include Windows.h.
The other problem I got is I can use SetForegroundWindow()function, but not AllowSetForegroundWindow()function in the same file. I got compile warning:'AllowSetForegroundWindow' undefined.
Anyone knows how to fix those. Thx.
mIchAel Liu
|
|
|
|
|
Michael Liu wrote:
PM_QS_PAINT or some other values to specify that only certain message should be processed.
Never heard of it. Are you sure it's not an example of a user defined message ?
Michael Liu wrote:
I got compile warning:'AllowSetForegroundWindow' undefined
I have never heard of this either. MSDN says it's defined for Windows ME and 2000 only ( I presume XP has it as well ). This means that any code that uses it will not run on W95/98/98SE/NT and also means you'll need to download the platform SDK ( about 500 MB, also available on CD ) in order to use it.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
PM_QS_PAINT :
MSDN give us four values to specify that only certain message should be processed. Do you know how to specify those values?
1. PM_QS_INPUT Windows 98/Me, Windows 2000/XP: Process mouse and keyboard messages.
2. PM_QS_PAINT Windows 98/Me, Windows 2000/XP: Process paint messages.
3. PM_QS_POSTMESSAGE Windows 98/Me, Windows 2000/XP: Process all posted messages, including timers and hotkeys.
4. PM_QS_SENDMESSAGE Windows 98/Me, Windows 2000/XP: Process all sent messages.
AllowSetForegroundWindow():
But I can use SetForegroundWindow(). This function needs the same requirements as AllowSetForegroundWindow().
Thx.
mIchAel Liu
|
|
|
|
|
Michael Liu wrote:
PM_QS_PAINT
Ah.. I did not know about it because I've never used it. Apart from GDI+ and transparent windows, I don't think I've ever used anything that requires the SDK. Look at the requirements you just posted and you'll realise I've answered your question. You need the SDK.
Michael Liu wrote:
But I can use SetForegroundWindow(). This function needs the same requirements as AllowSetForegroundWindow().
Not true. "Minimum operating systems Included in Windows 95, Windows NT 3. "
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
|
I've installed the latest SDK. How can I use the latest SDK with VC6? Thx.
mIchAel Liu
|
|
|
|