|
lordmickel wrote:
This is homework - kind of. I'm not taking classes as such, just dabbling a little.
Cool - I applaud that you're writing your own list then. Once it works, you'll understand how they work, and you should then use the STL exclusively
What happens when you step through the code in the debugger ? Are your values getting stored correctly in the list ? What about the pointer values as you step through, where do they go ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Thank you, thank you! ........ I'm not really familiar with stepping through the code, MS VC++ doesn't seem to be too helpful - or perhaps its just me. Unfortunately I can't really answer any of your questions exactly.
When I ran the debugger, the command prompt popped up and began running the program. When it had finished it produced this:
Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
The thread 0xF9C has exited with code 0 (0x0).
The program 'C:\Program Files\Microsoft Visual Studio\MyProjects\text_class\Debug\text_class.exe' has exited with code 0 (0x0).
Is there a better, more user friendly compiler that I could use that would be able to step through the code properly? I can't seem to get VC++ to do it
Thanks again,
lordmickel
|
|
|
|
|
lordmickel wrote:
Is there a better, more user friendly compiler that I could use
No.
lordmickel wrote:
that would be able to step through the code properly? I
The problem is not the compiler
Use F9 to set breakpoints ( they look like a big black circle on the left margin, make sure you're building a debug version and hit F5. Then VC++ will stop at the breakpoint and allow you to step through the code, set and check variable values, etc.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
If you need to 'prove' that certain elements (an element of a list contains a value and a pointer to the next element) are members of a list, then the most effective way is to start from the header element and print the value of the 'next' pointer, which is the address of the next element. Then you would move into the next element, print it's address (which resolves to the same as the 'next' pointer on the previous cell), and print the value of this new element's 'next' pointer and move on again, repeating the process.
This will bring forth an effective way to prove that certain elements are linked to each other. It will not work for circularly linked lists, because the loop would never end. For a non-circular list, the last 'next' pointer is a NULL value.
However, I see no reason in 'proving' that the elements are members of a list. Why would anyone need to do such ? Isn't it enough if the list fills it's purpose, whatever that purpose might be ?
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Antti, thank you for your reply. I had set something like that up in my classes but something isn't working correctly. I'm just doing this to prove that the list works - which at the moment it doesn't. Thanks for the circular linked list tip.
Thanks again,
lordmickel
|
|
|
|
|
Your first problem is that you are not storing valid pointers in your list. Try replacing the load code with,
details * driver = new details ;
driver->enter_driver_name();
output.DisplayDriverName(driver->get_name());
list.add_driver(driver);
And to print the contents try,
details* pDriver = list.getFirstDriver();
while ( pDriver )
{
cout << "name: " << pDriver->get_name() << "\n" << endl;
pDriver = list.getNextDriver () ;
}
Note I haven't suggested changed anything in your details or list classes which are basically working... Although you haven't made any attempt to manage memory, a 'package' should probably be able to delete a 'details' and a 'driver_list' should probably have a destructor that deletes all the packages.
Paul
|
|
|
|
|
Paul, please forgive me for the extremely late reply. I've changed the code and it works perfectly, thank you so much for your very helpful reply!
Thank you,
lordmickel
|
|
|
|
|
Does anyone have ideas on how i can retrieve the following system information:
1. processor serial #
2. hard-disk serial #
Thanks
larry_larry
|
|
|
|
|
GetVolumeInformation() will get you a disk's serial number.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
For the processor serial number, you have to dive into assembly language, but mixing assembly and C++ is not hard. See this Intel PDF[^] for details of the CPUID instruction and how to use it. Bear in mind that a) onyl Pentium III and above actually support the CPU serial number b) it can usually be turned off in the BIOS, even if the processor supports it.
For the hard disk serial number, if you mean the volume serial number, then Ravi's answer is all you need. If you're after the physical serial number that the manufacturer puts on a drive, that's more tricky, since you'll need different approaches for IDE and SCSI drives, and even then the actual physical disks may be connected to a RAID controller, which is "hiding" the actual hardware.
|
|
|
|
|
Graham Bradshaw wrote:
Bear in mind that a) onyl Pentium III and above actually support the CPU serial number b) it can usually be turned off in the BIOS, even if the processor supports it.
and c) in Windows, only device drivers have the required privilege level to use the CPUID instruction.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
in Windows, only device drivers have the required privilege level to use the CPUID instruction
Are you sure that's true? I've just stepped though a program we have here that uses the CPUID instruction to get the vendor string and other info, and I was running VC6 interactively on the desktop (with Administrative privileges on a WinXP SP1 machine). I'm not using a device driver, just running a desktop application.
|
|
|
|
|
Graham Bradshaw wrote:
Are you sure that's true?
As I recall, CPUID is a ring-0 privileged instruction. The Windows kernel must be implementing an exception handler and performing the CPUID on behalf of the application.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Well, if you want Physical Numbers and you do not want to go into device driver writing, the best option is to go to WMI. WMI provides such classes which can provide you these things. Look at Win32_Processor and Win32_DiskDrive in MSDN. This will help you.
Imagine that you are creating a fabric of human destiny with the object of making men happy in the end, giving them peace and rest at last, but that it was essential and inevitable to torture to death only one tiny creature..and to found that edifice on its unavenged tears, would you consent to be the architect on those conditions? Tell me, and tell me the truth!
-Fyodor Dostoevsky, The Brothers Karamazov
|
|
|
|
|
|
|
1)How do u access functions that are within structures and make them return a value to not the main but to another (void) function ? ( Dunno if qn is phrase is correctly ??)
2)Below is an excerpt from a vending machine program in C++ but how do u convert to C without using ::(the scope resolution operator) ? or Is the below program unable to be converted to C...
BTW: some reasoning of the program may be wrong especially the data inside Convert_to_Denom as this part is wat me coded moiself...^^;;
Mani Thks for all who readin tis
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
struct coins{
int denomination;
void setDenom(int);
int getDenom();
};
struct machine{
struct coins ten, twenty, fifty;
};
void Convert_to_Denom(struct machine *m);
main()
{
struct machine *mac;
Convert_to_Denom(&mac);
return 0;
}
void Convert_to_Denom(struct machine *m)
{
m->fifty.setDenom(50);
m->twenty.setDenom(20);
m->ten.setDenom(10);
printf("%d",m->fifty.getDenom());
printf("%d",m->twenty.getDenom());
printf("%d",m->ten.getDenom());
}
void coins::setDenom(int D)
{
denomination = D;
}
int coins::getDenom()
{
return denomination;
}
|
|
|
|
|
1. The question is not phrased reasonably. But this is how I understand it "How can I call a function inside a structure ?" and "How can I determine the location where the return value is stored ?"
For the first, calling a function inside a structure is just like calling any other function, the difference is that you need to have an object of the structure and use the member-of operator (. or ->). An example:
struct coins
{
void Function1(void) {}
void Function2(void) {}
};<DIV>
int main(void)
{
coins objCoin;
objCoin.Function1();
objCoin.Function2();
return 0;
} In your code piece, the Convert_To_Denom function will not work, because you have not initialized the pointer 'mac' before passing it as a function parameter. What you are doing is declaring a pointer-to-struct type, but you're not assigning it i.e. it does not point anywhere. If you use this pointer as is, the program will cause a run-time error. To make the code work, you must remove the asterisk from the declaration of 'mac'. This way, you will create an object of structure 'machine', and pass the address of this object into the function, which will then use the created pointer to access the members ten, twenty and fifty of the structure.
For the second question, you can nest function calls inside each other, if the return values and parameter types match. An example:
int Function1(void) { return 1; }
void Function2( int nValue ) { printf("%d", nValue); }<DIV>
int main(void)
{
Function2( Function1() );<DIV>
return 0;
}
Does this answer your questions ? If not, rephase your question, spell check it and write it in clear, plain english. Do not use abbreviations or other things which might leave your question unclear to other readers. For example, the 'qn' does not mean anything unless you can decipher it from the sentence context. If the sentence context is unclear or mistyped, the entire idea of the sentence (and thus your question) will be ruined.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
hi there
i've made an activeX control which is capable of playing wav files. i was wondering how i could use this control so that i could actually hear the content on the web using IE or any other browser. Also the reason i've developed this control is that i need to play vox files which are automatically converted through the control. Any ideas,opnions or workarounds on how i could use this control to stream on the web or local lan? also are there any open source or free vox converters or players available?
Thanks
|
|
|
|
|
The Bass libraries at http://www.un4seen.com[^] allow you to play streaming audio. Commercial use requires a licensing fee. Speaking from personal use, I highly recommend these libs.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hello.I have a small problem.
I cannot insert new Items in my Toolbox.
To insert I can, but those are then grey and
not clickable.Thus, I can not use her.
It would be nice, if someone says to me, where the problem lies.
It concerns Visual Studio.Net 2003.
I thank ahead.
|
|
|
|
|
If I am not mistaken, you want to insert items in the Toolbar (not Toolbox). The items in a toolbar will remain grayed unless you write a handler for those items. Just right-click the item in design view and click Add Handler. A Wizard will appear which will do the remaining stuff.
Imagine that you are creating a fabric of human destiny with the object of making men happy in the end, giving them peace and rest at last, but that it was essential and inevitable to torture to death only one tiny creature..and to found that edifice on its unavenged tears, would you consent to be the architect on those conditions? Tell me, and tell me the truth!
-Fyodor Dostoevsky, The Brothers Karamazov
|
|
|
|
|
I need a timer.In Toolbox, in Kontexmenu ' Add new Item ' select, come a window with different new tools, ' Timer ' mark and to ' OK ' click.In Toolbox came, but grey and not clickable.
|
|
|
|
|
my application is based on touch screen and use listctrl to list all user,so i want to set list height to make user to select list item easily.how can i do it?thanks.
Happy Gemini
|
|
|
|
|