For those new to message boards please try to follow a few simple rules when posting your question.
Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
Keep the subject line brief, but descriptive. eg "File Serialization problem"
Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
No advertising or soliciting.
We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
Other application can print out without problem ? Have tried to print to another printer ? Or, have you tried to run that command on another machine ? You can find more if you do some debugging on your code ...
<l>I am trying to learn c++ programming language and am still an amateur at it. I have a problem with "passing arrays in a function" and all am asking is what would be the easiest way to handle this problem?
*sometimes*. And it may very well depend on the platform.
I have a communications system that transmits data using tags and a parser. I have upwards of 500 data elements that can go back and forth. The initial implementation used a simple linear search for finding a passed tag. As time passed, the tag set became larger and larger.
Hey, this is a good place for a mapped data set, allowing me to find the tag quickly I thought. The map turned out to be 3 times slower than the linear search. Never did figure out why. Showed the sample code to someone who loves the STL and has a lot more experience than I do. No idea. Someday I'll get back to it.
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
constexprint Indices = 4096;
constexprint Size = 512;
externconst string tag [Size];
int linear_search(const string & s )
for (int n = 0; n<Size; ++n)
if ( s == tag[n]) return n;
constexprint Iterations = 1000000;
std::map<string, int> mtag;
for (int n=0; n<Size; ++n)
int sum = 0;
for (int n=0; n<Iterations; ++n)
int i = idx[n % Indices];
const string & s = tag[i];
k = linear_search( s );
auto it = mtag.find(s);
k = it->second;
cout << "sum " << sum << endl;
tag is an array of 512 randomly generated strings (having length betwween 4 and 12)
idx is an array of 4096 randomly generated indices (for quickly gatering a candidate)
g++ -D LINEAR_SEARCH -Wall lookup.cpp -o lookup_linear_search
g++ -Wall lookup.cpp -o lookup_map
And if you are on Linux, then you probably want to look at gtk or QT. I'm not sure what Mac uses these days.
There's dozens of tool-kits available for Linux and Windows, many are cross-platform, too. Use google to find something you like, and suits your needs.