Thread: Need help plz

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    29

    Unhappy Need help plz

    Hello,
    im still newbie in c++ programming.
    i like programming so much.
    hope you all can help me.

    This is my program :

    Code:
    CODE REMOVED
    Problem 1 :

    I used file class to store the student information,but i just can store one student infomation only in the file class.I tried to use FOR LOOP but still got error.So,how can i store more student info ?

    Problem 2 :

    How can i modify student info by searching student id ?

    Problem 3 :

    How can i remove student by searching student id ?

    Problem 4 :

    When i inserted marks to the students,the result shows numbers like this 2434830 ?Why it doesnt show the marks that i put ?


    For your information,im using DEV-C++ to run this program.
    Last edited by vearns; 01-01-2006 at 08:25 PM.

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Your formatting is disgusting. You don't indent, you don't use whitespace, you don't use a right margin, you aren't consistent with your braces... give me a second to format this properly and I'll answer your question.

    As it seems, this appears to be an assignment a class would hand out. If it is, don't lie. I'll know. I always know.

    ...and what the hell is this supposed to be:
    Code:
    cout << "" << endl;
    Problem 1 :
    Try using ios::app rather than ios::out
    Problem 2 :
    Pass it to the function, then use a loop and compare the search ID with all the students ID's
    Problem 3 :
    Same as Problem 2
    Problem 4 :
    Because your logic is messed up. Try entering a student... entering marks... then entering another student.
    Look at the second student's marks... don't they look familiar? Why would that be?
    Last edited by SlyMaelstrom; 01-01-2006 at 01:49 AM.
    Sent from my iPadŽ

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    29
    sorry,
    i am newbie

    I forgot to remove

    Code:
    cout << "" << endl;
    it is just to give some space so that my program become neat.

    Thanx for trying to help me.
    Last edited by vearns; 01-01-2006 at 01:44 AM.

  4. #4
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    I'm assuming you did it because you wanted two newlines. If that's the case then you should know you can use a '\n' or simply two endl

    Code:
    /* Two new lines */
    
    cout << endl << endl;
    cout << "Text \n" << endl;
    cout << "Text \n\n";
    Sent from my iPadŽ

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    14
    Have you tried ORing (|) ios::app to append to a file?
    Nos morituri te salutamus!

  6. #6
    Registered User
    Join Date
    Dec 2005
    Posts
    29
    Owh,
    thanks for the info.
    so,can you tell me how to solve the problem ?
    i keep trying and always got error.

  7. #7
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    I told you how to solve every problem.
    Sent from my iPadŽ

  8. #8
    Registered User
    Join Date
    Dec 2005
    Posts
    29
    Can you show me the code for problem 2 and 3 ?
    Last edited by vearns; 01-01-2006 at 04:16 AM.

  9. #9
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    How about reading my first post... where I answer your questions one by one. If I had a finger to point it out to you I would probably use it to poke you in the eye right now.

  10. #10
    Registered User
    Join Date
    Dec 2005
    Posts
    29
    hahaha...sorry...just edited my post.
    Can you show me the code for problem 2 and 3 ?

  11. #11
    Registered User
    Join Date
    Dec 2005
    Posts
    29
    the first problem has been solved.

    what function should i use for problem 2 and 3 ?
    Last edited by vearns; 01-01-2006 at 04:22 AM.

  12. #12
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    It might look something like this:
    Code:
    int currStud, studID;
    
    cout << "Enter the Student ID you wish to Edit: ";
    cin >> studID;
    
    currStud = 0;
    while (studID != students[currStud].ID && currStud < studMax) {
       currStud++;
    }
    
    if (currStud == studMax)
       cout << "Student not found." << endl;
    else {
       cout << setw(15) << left << "ID Number" << students[currStud].ID << '\n'
    	<< setw(15) << left << "First Name" << students[currStud].fName << '\n'
    	<< setw(15) << left << "Last Name" << students[currStud].lName << '\n'
    	<< setw(15) << left << "Date of Birth" << students[currStud].DOB << '\n'
    	<< setw(15) << left << "Grade 1" << students[currStud].Grade1 << '\n'
    	<< setw(15) << left << "Grade 2" << students[currStud].Grade2 << '\n'
    	<< setw(15) << left << "Grade 3" << students[currStud].Grade3 << endl;
    }
    
    cout << "What would you like to modify? \n>";
    /* The rest of the code... */
    Sent from my iPadŽ

  13. #13
    Registered User
    Join Date
    Dec 2005
    Posts
    29
    i copy and paste your code to my code and i modified some of undeclared variables still got error.
    i dont know studMax and setw is referring to what.

    can u do based on my coding ?

  14. #14
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    For future reference, never ask someone to write your code for you.

    setw() is a function in iomanip.h and isn't nessassary, it just formats your code. The same thing with the left keyword. studMax is refering to the number of students you have in your database. I didn't write the code for you to copy and paste into your program and if you aren't willing to spend 5 minutes to figure out how it works then perhaps you don't like program as much as you thought.

    ...by the way. HAPPY NEW YEAR... err 6 hours ago.
    Sent from my iPadŽ

  15. #15
    Registered User
    Join Date
    Dec 2005
    Posts
    29
    thanks for your help
    im learning new codes now.
    i just have basic.


    hope you dont mind to share with me.

    hmm.....

    how can i search the student id based on the file class ?
    i mean,the program will search the student id from database file.
    what function should i use ?

    one more thing,how can i contact u ?
    can u gimme email @ ym id.
    i tried to connect to your irc server but connection refused.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can any1 plz make this assignment
    By jean in forum C Programming
    Replies: 17
    Last Post: 05-13-2009, 09:19 PM
  2. plz help me...
    By sweetchakri in forum C Programming
    Replies: 1
    Last Post: 03-03-2009, 11:50 PM
  3. [Request] Need Help Plz
    By TylerD in forum Tech Board
    Replies: 4
    Last Post: 01-03-2009, 09:54 AM
  4. Anyone plz help me
    By Rose_Flowers in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 09-17-2003, 12:01 PM
  5. help plz plz
    By nsssn73 in forum C++ Programming
    Replies: 2
    Last Post: 06-03-2002, 08:44 AM