Tuesday, July 28, 2009

C++ project help?

Hi Everyone, I have a c++ project due in a while and I need help. Attached is what the project actually calls for me to do, but there are some things that I'm not sure how to tackle. How should the input file be formatted? I never understood infile and offile all that well so I'm not sure how to tackle that. Also, how do I allocate memory? I'm not exactly sure how to do this, but once I know how to get it in and everything, I think I know enough structures to get through it on my own from there.





Thanks!





http://www.hcaelxxam.com/Project.txt

C++ project help?
Format the input file in whatever way you'd like to make it easy to read. In real life we'd probably use quotes and commas, so it might be like:





"1","Bill","Gates","FR","123456789","W...


"2","Oprah","Winfrey","SO","987654321"...


etc.





You have to strip the quotes and commas from the lines as you read them in, but they have the advantage of helping you identify where each field starts.





Allocate memory with new. So:





struct StudentInfo *pInfo = new struct StudentInfo;





(I think that's right; it might be just "new StudentInfo;" without the "struct".)





I hope you have some time to work on this. You're asking questions about the easy part of this assignment. There's a lot to do once you get past reading the data.
Reply:The above answers are not 100% correct. So either code it yourself or else you may contact a C++ expert at websites like http://askexpert.info/
Reply:You can format the as your wish but you should read it as it is


because you only know how u formatted it





example





employee_number%26lt;single space%26gt;employee_name%26lt;singlespace%26gt;salary





Rajkumar 007 100





insted of space you can use special charactor also





This is how u have to format the file





For allocating memory use the keyword new in C++ for class





define the structure as your requirement and allocate memory for that





example





class abc


{


private:





int emp_no;


chat emp_name[30];


float emp_sal;





public:





%26lt;define methods as your wish%26gt;


%26lt;specfy the pointer variable depends on your structure%26gt;


}





create a memory for the above class by the following code








abc a= new abc();

deliver flowers

No comments:

Post a Comment