|
I know it is late but can someone help me with this, I know sh*t about c++ but I have to have this stupid course and have to get his assignment done can someone
|
|
|
|
|
A couple of things.
1/ No-one can help you if you don't post the question.
2/ Hopefully no-one will help you if you just post your assignment and expect a free ride. I'm sure everyone will be keen to help if you post your attempt at the problem and explain where you are stuck. If you 'know s*it' about C++, then it probably means you need to study more. Unless you're *never* going to look at C++ again, there is no point us helping you pass something you know nothing about. You're only going to find the cost of entry in terms of learning what you're supposed to know will increase the further you go without knowing your stuff.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
I understand what you are, and I respect that. My problem stems from a teacher who can't teach and when he tries he confuses the sh*t out of the class. Now I'm not trying to blame it on the teacher. but right now I am so lost I'm stuck at start, and I'm not sure what to ask as my question. I know this should be a simple assignment but I am finding it hard at the moment. I think all I need is alittle help getting started in the right direction and I can take it from there!
|
|
|
|
|
If your teacher is a moron you should complain, you have a right to be taught well. Either way, you should buy some books and teach yourself instead.
That being by the by, I'd be happy to give you some pointers, but you're yet to say what the assigment is. I assume you need to write something ?
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
Write a program that evaluates simple mathmatical expressions. the program reads one expression at a time from the user, evaluates it,and stores the result in an array. sort the expression and result in descending order of result values, and print them out. allow for a maximum of 25 expressions. ther will be three source files: main,eval and ch2int.
|
|
|
|
|
In other words a calculator ? Do you know how to do the following:
1/ read input from the user
2/ create an array
3/ parse a string ( I presume this is what ch2int will do, parse for an operator and a number )
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
main.cpp
use getline to read the expressions. each expression will consist of one operatorand two operands. the operands will be intergers. invoke the function eval to evaluate the expression and store both the expression and result into arrays. next, sort the expressions and results in descending order of results and printthem out. allow for a maximum of 25 expressions. continue this process until the user selects an option to exit.
|
|
|
|
|
And how much of this do you know how to do ? Do you know how to read in the line ? Do you know how to evaluate the result to extract the numbers ? What are you allowed to use ( can you use STL for example ).
Console app or not, Nish is right and your teacher needs shooting. There is no reason this can't all be done in one class, in one .cpp file.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
I know he need shot. i don't understand any of what you said and this project is due tomorrow. I had a freind who said he would help but he had to go home to his grandfather funeral yesterday so I am needing some help.can some one help
|
|
|
|
|
I said:
And how much of this do you know how to do ? Do you know how to read in the line ? Do you know how to evaluate the result to extract the numbers ? What are you allowed to use ( can you use STL for example ).
You said:
i don't understand any of what you said and this project is due tomorrow.
Bloody hell. I am astounded that it didn't occur to you before now that you were not learning anything and that you should be. What course are you doing ? Is this the only computing component ?
You're saying this course has had no marking up until now, and if you write this program you will pass ? Is everyone in the class in the same boat ?
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
6 people dropped the course the other day, and we can use anything we want. as far as I can tell the teacher knows dick about c++, up until this point it was goin ok, the project seemed fairly simple, then bam this one and the teacher is so confusing. and the reaosn i took the corse was to learn c++. I knbow asp and html and web programming, so I thought I would learn a real programming language. and I get stuck with the teacher who know nothing. or at least he can't convey it!!!
|
|
|
|
|
thank guys for all the help, I really appercaite it hope fully I can figure something out in the morning. but the code from nish will help greatly. agina thank you very much. if you have any more coments or code please send them to mrthump@hotmail.com again thank you very much!!!!!
|
|
|
|
|
It must have been one hell of a short course if it had 'gone well' but you didn't know any of the things I asked you. I really recommend you buy some good books, and as for this course, that you let people in charge know that the teacher has let you down.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
I've done a simple version of eval for you. You can modify it to suite your needs.
int eval(char *s)
{
int res=0;
char *a;
if((a=strchr(s,'+'))==NULL)
if((a=strchr(s,'-'))==NULL)
if((a=strchr(s,'*'))==NULL)
if((a=strchr(s,'/'))==NULL)
if(a==NULL)
return 0;
char *b=a+1;
int v2=atoi(b);
switch (a[0])
{
case '+' :
res=atoi(s)+v2;
break;
case '-':
res=atoi(s)-v2;
break;
case '*':
res=atoi(s)*v2;
break;
case '/':
res=atoi(s)/v2;
break;
}
return res;
}
Regards
Nish
Sonork ID 100.9786 voidmain
|
|
|
|
|
there will be three source files: main,eval and ch2int.
OUCH!!!
If your teacher said that, then you are right as to his being a moron. He prolly took it out of some old C text book that was written by a similar moronic author.
Three source files for a program to evaluate a simple mathematic expression!! and what's more! Even their names are specified. One of those names is ch2int which prolly means write a source file to convert char to int [which is auto-done by C-compilers as far as I know]
Like Christian said, GO COMPLAIN ABOUT THAT IDIOT
Nish
Sonork ID 100.9786 voidmain
|
|
|
|
|
the file is a console app.
|
|
|
|
|
I find myself needing to read/write all of the class member variables to and from an ini file. The ini file contains data for other classes as well.
I'm looking for a cool way do this. I need a member variable of whatever type, a name for that variable in the ini file, and read/write routines that work off of some kind of list structure. Any ideas?
Todd Smith
|
|
|
|
|
How about Get/WritePrivateProfileStruct()?
---
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
That doesn't really work for what I need.
So far what I've come up with is to use a #define and create a .inc file which I will include in a .h and a .cpp file. The .inc will do different things when it's in the .h vs. in the .cpp. When I include the .inc in a .h file it will declare the member variables. When I include the .inc in a .cpp file it will create code to add the member variables along with a name to a map or something. I haven't worked out the details yet.
Todd Smith
|
|
|
|
|
If you're using MFC and your object is derived from CObject you can use CArchive with CMemFile, then save the contents of CMemFile to .ini using CWinApp::[Get|Set]ProfileBinary.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
What you're after is called reflection, the ability to access in runtime to the structure of a class. Efforts devoted to achieve some sort of reflection in C++ are usually very far-fetched (look for OpenC++ and Meta Object Protocol (MOP), for instance). Nevertheless, it is possible that some kind of library exists fith more modest objectives that suits your needs.
Good luck
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
How can I drag icon in CListCtrl ? Just like Windows Desktop!
|
|
|
|
|
See MFCDRAG and maybe LISTHDR samples in MSDN. Maybe it will help.
|
|
|
|
|
Does anyone know how to detect if a item was checked or unchecked in a CTreeCtrl? I took a look at the CTreeCtrl and it seems that there are no messages for this kind of thing.
|
|
|
|
|
Sorry - no special notification for that. You'll have to handle WM_LBUTTONDOWN and use CTreelCtrl::HitTest. If returned flags have TVHT_ONITEMSTATEICON bit set, it was a click on checkbox.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|