|
You could start by formatting your code properly by the use of <pre> tags; click the code button. Then try explaining exactly which part of the code has the problem and what that problem is.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I'm having problem with both writing and reading the linked list to the file. To be honest I don't know which is giving me be problem writing or reading...Any help in creating codes that read and write to and from a liked list would be appreciated.
//code used for writing to the linked list
template<typename t="">
void DisplayEmployeeRan(List<t> &listObject3)
{
char ans; //answer to store 'y' or 'n'
Employer emp;
int in;
ifstream RanFile("Employer.dat",ios::in |ios::binary);
if (RanFile)
{
while ( !listObject3.isEmpty( ))
{
cout <<"\nEnter employee's id number to"<< " display ";
cin >> in;
RanFile.seekg(sizeof(Employer) *(in - 1));
RanFile.read(reinterpret_cast<char *=""> (&emp),sizeof(Employer));
//if not eof show data
if(! RanFile.eof())
{
//Display the processed
// info for the employee
listObject3.print();
}
cout << "Display another "<<"employee's information? [y/n] ";
fflush(stdin);
ans = ' ';
while (ans != 'y' && ans != 'Y'&& ans != 'n' && ans != 'N')
{
ans = _getch();
}
cout << endl;
if (ans == 'n' || ans == 'N')
{
exit(1);
}
}
}
else
{
cout <<"Error - random files could not be opened.";
}
}
|
|
|
|
|
Please edit your message and format the code properly as previously suggested. Unformatted code like the above is not easy to read.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
See here. It may not be exactly what you are looking for, but it might point you down the right path.
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
> Hello., I followed your wave recoding and playing code from this Voice Recording/Playing back using simple classes[^]
>> That helps me a lot
>> Now i want to write buffer data to a wave file
>> Can any one tell me how to write a wave file from buffer
|
|
|
|
|
Member 8701235 wrote: >> Can any one tell me how to write a wave file from buffer
If you are using MFC, check out CFile . If you are using Win32, check out WriteFile() .
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
|
When I start a new Win32 project how to load picture in the white window, say with open file dialog (selected from menu above) :?:?:?:?
|
|
|
|
|
Have you tried calling BitBlt() in your WM_PAINT handler?
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I have an app, developed in VC6.0 which uses a Date Time Picker control to display the time in a CTime object using HH:mm:ss format. This works OK on XP based PCs but when I run it on Windows 7 (32 bit) it displays the wrong time: A time of 00:00:10 is displayed as 16:00:10.
The Date Time Picker control is mapped to the CTime object using MFC DDX_DateTimeCtrl. The time value in the CTime object seems to be correct.
Has anyone come across this kind of thing before?
TIA
|
|
|
|
|
Sounds like the regional (i.e., locale) settings are different between the two machines.
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
hello guys... plz first consider this code.
<pre lang="c++">
void CMoveWindowDlg::MoveMyWindow()
{
CWnd* wind = GetDlgItem(IDC_UPDOWN); // Current button to which: this event handler is bound
ASSERT(wind!= NULL);
wind->GetWindowRect(&rect);
r.top = rect.top;
r.left = rect.left;
r.right = rect.right;
r.bottom = rect.bottom;
int height = rect.Height();
int width = rect.Width();
wind->MoveWindow(100, 100, width, height, 1);
}
</pre>
<b>1 - </b> Here I get the location and size in two things - <b>RECT r</b>, <b>CRect rect</b>. When I click on this button, it takes my button to the specified point. The problem is: if there is some other control already at that point like EditBox, this button will not work and the EditBox will come on top of it.
<b>2 -</b> I use another button to place this button back on the previous location by providing the location which I stored in <b>Rect r</b>, like this..
<pre lang="c++">GetDlgItem(IDC_UPDOWN)->MoveWindow(&r,1);</pre>
But unfortunately, this also does not place the buttun at its original place.
Problems are specified so whats wrong with this code?
|
|
|
|
|
1 And what is your question?
2 This:
overloaded Name wrote: wind->GetWindowRect(&rect); will give you screen coordinates while this:
overloaded Name wrote: GetDlgItem(IDC_UPDOWN)->MoveWindow(&r,1);
expects the coordinates to be in "client of the parent window space". Use e.g. ScreenToClient to convert screen coordinates to client coordinates of the parent window.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
Hi!
I've been asked in an interview whether we could do all the things that were possible in C++ in C also. I answered Yes. But the interviewer further asked why C++ if you can do all the things in C itself(Constructor, Destructor, Polymorphism,
Templates every thing is possible in C)? I don't know the answer. Can anybody explain?
|
|
|
|
|
Well I mysellf am new to tech world but I think it depends upon feature that a particular language supports. To print something on screen you use
- printf("The Sum is: %d", sum)
in 'C'. But in C++, you dont have to worry about the datatype like
- cout<<"The Sum is: "<< sum;
So you see some laguages are easier to develop with. Moreover, almost anything that can be done in C++ can also be done in Java. But Java does not support pointers while C++ does. So does this make C++ a better / worse choice than Java? NO: it all depends on the problem that we are going to address and of course, our own choice as well.
|
|
|
|
|
|
pix_programmer wrote:
Any other answers?
Thats is rude. I dont think I am going to get paid for sharing my thoughts with "your excellency".
|
|
|
|
|
overloaded Name wrote: Thats is rude.
Actually that's not so rude, because your answer is apparently incomplete.
Veni, vidi, vici.
|
|
|
|
|
but I think it depends upon feature that a particular language supports.
Thats what I wrote in first line. I think I should have replaced this line with: "Features such as OOP". I just said a more generalize sentence. I assumed OP knew that C++ was named "C With Classes" at first, but was renamed later.
CPallini wrote:
Actually that's not so rude
OK That is rude to some extent. Yet I confess my answer may have been incomplete and did not help, so no more replies from my side.
|
|
|
|
|
Don't get offended. I was joking, after all.
However introducing iostreams like one of major C++ achievements it is a common mistake.
Veni, vidi, vici.
|
|
|
|
|
IMHO, the most compelling reason to use C++ rather than C is 'classes', allowing Object Oriented Programming (OOP). Classes makes code more structured, easier to write, understand and maintain (and more stable). This is important, especially with complex applications. Polymorphism and other features are nice extras but I wouldnt say to choose C++ just for these features alone.
|
|
|
|
|
The advantage of C++ over C is Object Oriented Programming (OOP ). C++ supports OOP while C doesn't. That means you may write an OOP application in a fair clean and elegant way using C++ (you may write a C application following the OOP paradigms but your code would be more messy and your development time would be longer).
It is worthy nothing that OOP is not a panacea: it is best suited for rather big projects (say more than 100,000 lines of code) involving team of developers. Form smaller projects, in my opinion, OOP is overkilling and structured programming (the paradigm supported by the C language), is better.
Veni, vidi, vici.
modified 6-Apr-12 3:48am.
|
|
|
|
|
Spot on answer. 5!
==============================
Nothing to say.
|
|
|
|
|
Agreed on pretty much anything, except that I consider 100,000 lines rather small, and don't see any advantage in using C over C++ on smaller projects, as long as there are at least two developers working on it. OOP and the stricter syntax of C++ is great for avoiding errors based on misunderstandings of code use.
|
|
|
|