-
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 :
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.
-
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?
-
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. :)
-
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";
-
Have you tried ORing (|) ios::app to append to a file?
-
Owh,
thanks for the info.
so,can you tell me how to solve the problem ?
i keep trying and always got error.
-
I told you how to solve every problem.
-
Can you show me the code for problem 2 and 3 ?
-
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.
-
hahaha...sorry...just edited my post.
Can you show me the code for problem 2 and 3 ?
-
the first problem has been solved.
what function should i use for problem 2 and 3 ?
-
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... */
-
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 ?
-
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.
-
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.