|
Hi!
I had writed a program to read and transmit data in, out LPT Port.
start i transmit data out at data register(at address &378H; _outp(378,255) with value is 255 and then i read data in at data register(unsign integer x = _inp(378)value True is 255 but it return value is -1.
I know that in language C is auto check sign so i use a variable type is unsign integer to keep it(unsign integer x = _inp(378). but it too return -1. I don't know why. could you help me?
|
|
|
|
|
I know this isn't the question you asked, but why don't you just use normal Windows IO routines? _inp and _outp are not supported on NT/2000/XP. Well, they are supported but generated a fault.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
class Stock
{
friend ostream& operator << (ostream& s, Stock& stock);
};
ostream& operator << (ostream& s, Stock& stock)
{
s <<"Stock information: "<< stock.companyName<<" "<
|
|
|
|
|
You're almost there, in your Stocks operator << you need to iterate through each of the Stock objects in your array and add them to the stream. The code to do this will depend on what type of array you're using, but the basic idea is pretty simple:
for each Stock in the Stocks object
s << this_stock;
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
I could not understand what you said>
don't you think i need some sort of loop because i don't know how many objects
are stored in Stocks??
something like(i know this thing cannot work)
ostream& operator << (ostream& s, Stocks& stocks)
{
for(int i = 0; i <15; i++ )
return s << stocks.getStock(i)<
|
|
|
|
|
Yes, you do need a loop. That's what I meant by "for each Stock".
I can't tell you how to implement the loop because I don't know what sort of array you are using to store the Stock items. If it is a simple C array, then you can just use a loop with a counter:
for (int viItem = 0; viItem < m_iStockCount; ++viItem)
{
s << m_aStocks[viItem];
}
Also, you may want to have a closer look at Christian Graus' comment below because I have to admit to not knowing more than the very basics of ostream.
You might also want to have a good read of a good book on C++/C if the concepts of arrays is beyond your knowledge, because you're not going to get very far without it.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
how can you return s???
because if you return s you will only return the last value that s took in the last time thru the loop?
you know what i mean ?
like this bad code:
ostream& operator << (ostream& s, Investors& investors)
{
for(int i; i<investors.getNumOfInvestors(); i++)
{
s << investors.getInvestor(i)<<endl;
}
return s;
}
remember this is only a friend method and it only takes 2 argduments
ostream& operator << (ostream& s, Investors& investors)
|
|
|
|
|
Marwan wrote:
because if you return s you will only return the last value that s took in the last time thru the loop?
s is an ostream, and you should return the same stream that was given as a parameter. Your code isn't bad, returning s after the loop is the what the << operator should do.
|
|
|
|
|
I'm not sure what you're thinking of here, but the reason you return s is shown in your code:
s << investors.getInvestor(i)<
|
|
|
|
|
Additionally, this code is only a rudimentary version of what you want. You should also check the stream state, create an instance of an object whose name escapes me right now to take care of prefix and postfix operations, and also if you want formatting to work with this object, you should stream the data to an ostringstream first and pass it to the ostream all in one operation.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
This code would be a lot faster if you had a grow policy instead of copying the whole array every time you add 1 element. It would also probably be faster to use memcpy to copy the old array into the new one. Also, you should use the prefix ++ operator whenever you don't actually need the postfix one.
The line 'investorsList = temp' makes both point to the same list, which you then call delete on at the end. So investorsList then points to an array that has been deleted.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
dude, how did you manage to screw up the indentation that much?
Anyway, the code looks fine to me (you should uncomment delete [] investorsList; , and you really don't need a temporary array, but that shouldn't hurt it for now). Things unknown: is numOfInvestors being properly initialized? And what effect does insertionSort() have (is this a library funtion? i don't recognize i'm afraid...)?
farewell goodnight last one out turn out the lights Smashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
He must have found it - he deleted the question...
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
That's good. My answer looks less wrong this way
farewell goodnight last one out turn out the lights Smashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
|
It's kind of annoying for people to come along and read the answers but not the question. If you leave your question up, it means others can benefit from it, even if you found the answer.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
ok sorry about that Christian!
i will never do it again!
|
|
|
|
|
Let's say I do I search for schools on yahoo. How can I click the
next button on yahoo to continue searching for schools? I want
to store the schools I find and continue searching? Any ideas?
|
|
|
|
|
If the system uses querystrings, you could devise an app to pass the data to the server automatically be altering the querystring variables each time.
Simon
"The more I learn, the more I realize I don't know" - Colin Davies
Sonork ID 100.10024
|
|
|
|
|
write your own search engine in perl (about 5 lines)
|
|
|
|
|
I have tried the CTrayNotifyIcon in a fresh skeleton mdi app and the icon in the system tray appears as well
as the task bar which is not correct.
Has anyone either
[1] - got it to work correctly with an mdi app
or
[2] - experienced the same problems
I just want to get it going quickly.
|
|
|
|
|
CTrayNotifyIcon is only for adding the icon. If you dont want your app to show on the task bar you'd have to use your own techniques to avoid that.
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
... like ShowWindow(SW_HIDE) on the CMainFrame based class.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Hi,
In my application. I have a combobox.
But some items names are too long to be completly displayed.
Is it a way to display the full string, regardless of the CombBox width ?
I mean the drop down window should be greater than the width of the combobox itself.
Thanks,
Stephane
Stephane
www.exotk.org
|
|
|
|
|
Find the width of the longest string in pixels. Add the width of the borders (use GetSystemMetrics(SM_CXEDGE)*2 ) & then use SetDroppedWidth() (MFC) to set the dropdown width.
farewell goodnight last one out turn out the lights Smashing Pumpkins, Tales of a Scorched Earth
|
|
|
|