|
ISUstudent wrote:
...she is really confusing...
Which is usually a good indicator that you should either ask questions in class, or stop by her office after class for some specifics.
ISUstudent wrote:
PLEASE STAY IN TOUCH WITH ME AND HELP ME THROUGH THIS PROGRAM, I may even pay you some $$ for your help! I AM SERIOUS!!!!!
Begging is not very becoming. Ask your question(s). Be mature. Move on.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
DavidCrow wrote:
Begging is not very becoming. Ask your question(s). Be mature. Move on.
ROTFL!!!!
|
|
|
|
|
hello jason,
try this one.
//======================================================
// menu.h
#include<iostream>
#include<string>
using namespace std;
class CMenu
{
private:
int m_numChoices;
string m_menuItem[8];
public:
// Default constructor
CMenu();
// Special constructor
CMenu(int itemcount,
string item1,
string item2,
string item3 = "",
string item4 = "",
string item5 = "",
string item6 = "",
string item7 = "",
string item8 = "");
void run(char item);
int validateChoice(char item);
void printMenu(int item);
};
//======================================================
//======================================================
// menu.cpp
#include "menu.h"
// Default contructor
CMenu::CMenu()
{
// Initialize the number of menu items
m_numChoices = 0;
}
CMenu::CMenu(int itemcount, string item1, string item2, string item3, string item4, string item5, string item6, string item7, string item8)
{
m_numChoices = 0;
// Process only if the number of requested items is correct
if((itemcount >= 2)&&(itemcount <= 8))
{
m_numChoices = itemcount;
m_menuItem[0] = item1;
m_menuItem[1] = item2;
m_menuItem[2] = item3;
m_menuItem[3] = item4;
m_menuItem[4] = item5;
m_menuItem[5] = item6;
m_menuItem[6] = item7;
m_menuItem[7] = item8;
}// if((itemcount >= 2)&&(itemcount <= 8))
}
void CMenu::run(char item)
{
printMenu(validateChoice(item));
}
int CMenu::validateChoice(char item)
{
int return_value = 0;
char *ptr_tmp = new char;
*ptr_tmp = item;
*(ptr_tmp+1) = 0;
int itmp = atoi(ptr_tmp);
//cout << endl << itmp << endl;
if((itmp >= 1) && (itmp <= m_numChoices))
{
// We need to subtract 1 because the m_menuItem array is zero-based
return_value = itmp - 1;
}
return return_value;
}
// Developer Note
// I am assuming that this method will print only
// the menu item corresponding to the
// integer location
void CMenu::printMenu(int item)
{
cout << m_menuItem[item];
}
//======================================================
// main.cpp
#include "menu.h"
void main()
{
CMenu oMenu(3, "item1", "item2", "item3");
oMenu.run('3');
}
//======================================================
Some notes, i assume this is only for your studies. becuase there are some major flaw in the design.
when you try:
CMenu menu();
this is actually useless.
anyway, hope this helps.
|
|
|
|
|
i missed something
the printMenu method should be:
void CMenu::printMenu(int item)
{
if(item > 0)
cout << m_menuItem[item];
}
cheers
|
|
|
|
|
It should be
<br />
void CMenu::printMenu(int item)<br />
{<br />
if(item > 0 && item<=m_numChoices)<br />
cout << m_menuItem[item-1];<br />
<br />
}<br />
and you need to initialise m_numchoices in the constructor.
Mike
|
|
|
|
|
thank you guys so much!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
I will see what I can do....that code is SOOOOO HELPFULL!!!!!!!!!!!!
I'M SURE I WILL BE BACK TO ASK MORE QUESTIONS!
~ JASON
|
|
|
|
|
OK, I am writing an MFC app using Visual C++ 6. The problem is, my program works in the release mode, but it doesn't work in the debug mode (yes, NOT the other way around!). I traced the problem, and it seems that the problem stems from one of my classes, which has a member variables like:
private:
.... some other things...
float number1[30];
float number2[30];
In this class' initialization, I use a for loop to initialize this array to all zeroes. The problem is, it seems that number2's address space overlaps with some other variables, and this overlap corrupts my program, causing some access violation (not debug assertion). This does not happen in the release mode. Could someone point to me how I can deal with this problem? Thanks!
|
|
|
|
|
Are you looping from 1 to 30, or from 0 to 29 ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I am trying to read in a file, which was written using serialization (by someone else). The size of the variables present in the file from which I need to read is way greater than the stack size. So this is giving me problems like stack overflow. Is there any way to solve such problems? Please give me your suggestions .Thanks a lot
|
|
|
|
|
hemanth_phk wrote:
size of the variables present in the file...
Files don't have variables. A variable is something in your code that can contain the contents of the file, however.
hemanth_phk wrote:
...is way greater than the stack size.
Are you trying to read the file into a stack-based variable?
hemanth_phk wrote:
Is there any way to solve such problems?
Use memory from the heap instead.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I can't seem to open a listening socket on Windows Server 2003. The very same code has run on NT4 and Win2k for years. But when I try to run it on Win2k3, it fails to create a listening socket. The code is a C++ wrapper for the Windows Socket API (MFC Socket classes are mostly useless). I don't believe there is anything unusual about the way the code was implemented. It has never given us any trouble in the past.
I guess my question is this: Is there something more that I must know/do in order to run a socket server (i.e. listening socket) on Win2k3. Is this part of MS's Secure Computing Initiative. Or am I just overlooking the obvious? Any help would be greatly appreciated.
Thanks,
Jon
|
|
|
|
|
Win2k3 requires a listening socket to be bound to a specific IP, whereas Win2k and NT4 do not. We were not binding to a specific IP. One small change, and the code works on all 3 operating systems.
Jon
|
|
|
|
|
Hi,
We're getting the following error and we cannot figure out how to get rid of it. It is happening on only one person's pc and not others. The application(s) that he is compiling are simple MFC apps or even non-MFC apps. There is no use of ATL or COM. If anyone has any clues, please let us know. Thanks.
Regards,
Sanjeev
"fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>".
|
|
|
|
|
If you include any MFC header files after windows.h, then this error occures. For example:
#include "windows.h"
#include "afx.h"
The above code will cause C1189 error, but the following will not:
#include "afx.h"
#include "windows.h"
So, to avoid this error, make sure that you include windows.h at the end of all the includes.
Arsalan Malik
|
|
|
|
|
Arsalan Malik wrote:
#include "afx.h"
#include "windows.h"
So, to avoid this error, make sure that you include windows.h at the end of all the includes.
When using MFC, there's no reason to include windows.h as it has already been included.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi Folks,
Thanks for the tips but...
Please note that the compile error occurs on only one person's pc. If the project is compiled on someone else's pc, then there is no error.
Also, note that even on this one pc, the error only started occurring about a week ago. Previously, there was no such error. Nothing has been changed in the code.
It seems to me that maybe the wrong version of some file (probably .H) is being picked up from somewhere. I checked in the Tools - Options - Directories - Include files and it looks fine. This person has already uninstalled and re-installed Visual Studio without any success.
I'm hoping to find a solution for him before he goes re-formatting his drive .
Any other ideas? Please let me know. Thanks!!
-Sanjeev
|
|
|
|
|
skg747 wrote:
I checked in the Tools - Options - Directories - Include files and it looks fine.
What about the INCLUDE environment variable?
It's a long shot, but have you looked through the code for any #error directives?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
This is the only #error directive I see (in VC98\MFC\Include\afxv_w32.h):
#ifdef _WINDOWS_
#error WINDOWS.H already included. MFC apps must not #include <windows.h>
#endif
|
|
|
|
|
I'm trying to save a file to a server and getting a "The parameter is incorrect." exception.
<code>
CFile file;
CFileException ex;
if( file.Open(path, CFile::modeWrite | CFile::shareExclusive | CFile::modeCreate, &ex) )
{
try
{
CArchive ar(&file, CArchive::store);
ploan->Serialize(ar);
ar.Close();
file.Close();
}
catch(CFileException* pEx)
{
}
catch(CArchiveException* pEx)
{
}
catch(CException* pEx)
{
}
}
</code>
It creates a zero length file and fails. Any ideas??
Thanks!
ed
|
|
|
|
|
Does it happen if path points to some local (as opposed to a server) folder? Have you stepped into the CArchive constructor or the Serialize() method to see where the exception gets thrown? While the other two Close() methods can also throw an exception, I would rule them out for the time being.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks!!!
This doesn't happen on the local drive. Only on network drives. And it doesn't happen to everyone either. I have 3 clients out of 1000+ that have this issue.
ed
|
|
|
|
|
I'm leaning towards a permission-related issue. To verify, dummy up a little program that does nothing but create and write to a file on the network. Does that uncover anything?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Took a while but wrote a little app for them. There are 3 locations this happens at so far. The test app had the same result. It wasn't an CFile or CArchive exception rather it was caught in the CException catch block.
They all have the problem when they write to the server. When they change the path so that it writes to their C:\ drive there isn't a problem.
Thanks for the bandwidth!
ed
The absence of evidence is not evidence of absence.
|
|
|
|
|
I have noticed a "visual scrolling" problem with owner-draw list boxes (both mine and others) in XP. This occurs with both stand-alone list boxes and ones associated with a combo box. The problem occurs if the My Computer | Properties | Performance Options | Visual Effects | Smooth-scroll List Box option is checked. The animated scrolling generated by windows is okay unless you click on the scroll bar to generate page-up/page-down messages. With this, the scrolling animation visually appears to be going in the opposite direction as expected...but when the animation terminates, the appropriate update has occurred (e.g. the expected items are visual). This is quite obvious when the list box size is large enough and the items are different in appearance. This does not appear to occur with non owner-draw list boxes.
I cannot find any reference to this bug but it is clearly reproducible. Is anyone aware of a fix?
|
|
|
|
|
Can someone help me. I have two recordsets that are opened (ADO)
AdRecordSet and AdTimesRecordSet.
The data is then combined by the field AdID into a class / recordset SiteAdInfoSet (the instance is called CAddInfoSet)
I would like to sort CSiteAdInfoSet by m_NrPlays (int) in descending order (field came from AdTimesRecordSet.. I want to re-store the data back into CsiteAdInfoSet as to keep changes to a minimum.
I hope this is clear
Thanks.
TomH
|
|
|
|