|
WELL I HOPE ALL USERS ARE IN GOOD SPIRITS...FOR TOMORROW IS A FRIDAY AND RELIEF TO A WEEK.
I'M A FRIENDLY NEWBIE POWERUSER WITH AN OPEN MIND AND WEAK HEART.
I have a project for c++ and I need help for the first time. Source CODE IN C++
the word problem:
the department of motor vehicles administers a written driver's exam consisting of 20 multiple choice questions. an applicant for the drivers license exam answers these questions electronically and the answers are stored in a file named xxxxyyy.dat (where xxxx are the last four digits of the ID number, and the yyy are the first three letters of their last name) in other words, each applicants file will be uniquely named. the file containing the correct answers to questions is named ANSWERS.DAT
write a program that will read the contents of the ANSWERS.DAT file into an array (with the size of 20). program should read the applicants answer file into a second array (also 20) the logic of the program should the 'check' the applicants answer to a question and compare it to the 'correct' answer. the program should keep a tally of the number of questions correctly answerd, and the tally of incorrect answers. Finally the program should cout whether or not the applicant 'passed' or 'failed' the exam. they must answer at least 15 questions correctly to pass. program should indicate "PASS" or "FAIL" along with the number of INCORRECT and CORRECT.
following layout for program centered:
Department of Motor Vehicles
Driver's Exam
answered 99 questions correctly.
answered 99 questions incorrectly.
results for this portion of exam: XXXX
AND THATS ALL ALSO FOR AN EXAMPLE .DAT FILE '1278BOB.DAT' AND MULTIPLE CHOICE a,b,c,d
|
|
|
|
|
Unless you're going to use managed C++, you're in the wrong forum.
Aside from that, what are you asking?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Sorry I'm new in this forum. I'll get it right. I need help with an array that compares character contents in two files and outputs results #correct \ #incorrect with total & pass \ fail grade.
|
|
|
|
|
Cross-poster who wants us to do his homework.
|
|
|
|
|
you are an ugly person who is sick and needs help. must be all the meds.
|
|
|
|
|
Wow--like I really care what you think of me. How about playing by the forum rules and you won't get flamed?
|
|
|
|
|
well I never intended for you to show any concern, I know as well as anyone else who visits your pessimistically crap web page, that 'you' feel like your acomplishing some need for others. In all factuality its people like you that gives others a reason to break an ethical code in computing. Instead of lending a helpful insight, you show true characteristics of an unhappy person. So remove my name from your list.
Sincerely,
John
|
|
|
|
|
Sorry, you just made the top of the list!
|
|
|
|
|
Dear all ,
Will it possible to add the run time created dll to install in GAC.
If yes Pl Explain me.
In My Project i used third party Active x control so i add
that reference into the project. then try to provide the strong key
Strong key is attached then i try to add it in assembly info file
then try to build but it is giving me error
Error creating assembly manifest
|
|
|
|
|
Hi,
I'm using Visual Studio 2005 C++/CLI. I have an application that I would like to create a new version of. Obviously I don't want to recreate a bunch of dialog boxes, etc., so I copied my application from c:/Visual Studio 2005 Applications/myAppVersion1/myApp to c:/Visual Studio 2005 Applications/myAppVersion2/myApp. Here is my problem... I click on c:/Visual Studio 2005 Applications/myAppVersion2/myApp.sln to bring up Visual Studio 2005. Then I clean and rebuild the solution but when I run myApp there is a line that gets the current directory System::IO::Directory::GetCurrentDirectory() and it uses the directory for myAppVersion1. If I am running the solution from myAppVersion2 directory then why does GetCurrentDirectory() return the myAppVersion1 directory?
Thanks,
Buck
|
|
|
|
|
In the project's debugger settings, do you have a working directory specified?
In general, your app should set the working directory and not assume a certain
location
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
this is for a chat application...
I have to serialize an object from server and it has to be sent to client...
from client i have to deserialize it....
I successfully searialized the object and sent to client...
but when I am deserializing from client it is showing error...
"Unable to find assembly 'chatServerIDE, Version=1.0.3035.35765, Culture=neutral, PublicKeyToken=null'.""
please help me...
|
|
|
|
|
|
ohh thank you very much...
it is an superb tutorial...
Thanks Giorgi
Regards
Simnesh
|
|
|
|
|
Glad to help you
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
is there a way to convert an 'int __gc *' to 'int *' ?
thanks
|
|
|
|
|
never mind, I found the solution
int __pin *pinp = &i;
|
|
|
|
|
Hello Dear Friends,
I've one problem.
Suppose I've a list of open files that is opened by the application using
ShellExecute API.
How can I determine that a particular file is Open Or Close in managed c++ code?
ritz1234
|
|
|
|
|
hello
i want to open ports like 21,23,80,8080,56326 or any unknown ports
how can i do this using c++ ??
plzzz help me
|
|
|
|
|
What do you mean by "open ports"?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes[^]
and so did the delete even though it told me it failed!
led mike
|
|
|
|
|
|
I encountered an absolutely insane problem with BinaryStream I/O of native classes that I was wondering if someone could shed some light on. I do have a work-around, but the whole thing just doesn't make any sense to me...
First, I have a class, "CMyBinaryIO" to handle the streaming. The Save(IntPtr myData, int iSize) method takes 2 params: an IntPtr to the data, and a integer to indicate the expected byte size. I use Marshal::Copy(...) to copy the structue into an array of bytes, and then pass that array to the BinaryStream::Write(...) method. Simple enough.
OK. Now the dirt... Consider the following, simple code snippets:
<br />
UMyParent<br />
{<br />
public:<br />
int iParentA, iParentB;<br />
};<br />
<br />
UMyHelper<br />
{<br />
public:<br />
int iHelpA, iHelpB;<br />
};<br />
<br />
UMyChild : public UMyParent<br />
{<br />
public:<br />
int iChildA, iChildB;<br />
UMyHelper uChildHelp;<br />
};<br />
If UMyChild has a Save() method that does this...
<br />
CMyBinaryIO::Save((IntPtr)this, sizeof(UMyChild));<br />
...it works. I can do a similar read operation and retrieve all the data properly. HOWEVER, I cannot read/write the binary file in any environment other than the one it was created in. In other words, if I was running the application through the IDE, I cannot read the file by running the EXE directly!!! If I create a file by running the app directly, I can't even read the file by running the exe directly on a different computer!!!
To be specific, if I created the file running through the IDE and I try to read the file by direct execution, the program acts like it read the data just fine. However, when I try to invoke any other method in the UMyChild class (maybe pChildInstance->DoSomething()), I instantly get a crash with a nice message that says something about not being able to access memory, and that the memory is possibly corrupt.
Now, here's the real confusing part. If I do this in the UMyChild::Save() method...
<br />
CMyBinaryIO::Save((IntPtr)&iParentA, sizeof(int));<br />
CMyBinaryIO::Save((IntPtr)&iParentB, sizeof(int));<br />
CMyBinaryIO::Save((IntPtr)&iChildA, sizeof(int));<br />
CMyBinaryIO::Save((IntPtr)&iChildB, sizeof(int));<br />
CMyBinaryIO::Save((IntPtr)&uChildHelp, sizeof(UMyHelper));<br />
...the the file can be created and re-read on ANY machine, and is completely cross-compatible between IDE and "live" execution. And when I call pChildInstance->DoSomething(), I don't get the corrupted memory messages!!!
I thought it might have something to do with .NET trying to write complex unmanaged types. But look closely at the code... The app does not require the UMyHelper members to be written one field at a time. The "uChildHelp" member can still be written as one chunk of data.
Does anyone have any ideas on how this could possibly be? Thank God I can at least do the single-member read/write to get around the issue, but it doesn't seem like I should have to. Why can't I pass the "this" member with the appropriate size calculation of the inherited class with all its members?
Thanks.
|
|
|
|
|
First, the code you posted does not even compile. Second you are doing what when reading? You did not post any reading code.
Xpnctoc wrote: However, when I try to invoke any other method in the UMyChild class
What method, there is no method in that class.
led mike
|
|
|
|
|
I was providing abbreviated code, as the focus of the problem is on the data members, not the methods. In "real life", the code is thousands of lines long, containing scores of members and hundreds of methods. The "DoSomething()" method I refer to is actually a method containing several hundred lines of OpenGL rendering code. This code is all straight-forward calls to the OpenGL API, using the class members to define 3D coordinates, rotations, transformations, etc. There are no tricky pointer operations or anything like that which could possibly be triggering the so-called memory errors.
Remember, all of my code works fine if either (1.) I only open the saved binary file while running the application in the same mode that created the file (IDE vs. "live" execution) OR (2.) I use the above-described work-around. Since I can get consistent behavior in either circumstance, I am convinced the problem lies in the BinaryStream class when trying to serialize unmanaged classes as one solid memory chunk.
|
|
|
|