I just extended the code.
I don't know how to achieve my end purpose. My purpose is to enter data of some students, then display that data inside some border made from "*" or "=" using some user-defined function.
// displaying students' data using a user-define function
#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;
/////////////////////////////////////////////////////////////////
struct STUDENT
{ string name, DofAdm, sex; int age, marks; };
/////////////////////////////////////////////////////////////////
void prntborder();
int main ()
{
STUDENT s1, s2;
cout << "enter the details" << endl;
cout << endl;
cout << "enter details of first student" << endl;
cout << "enter name: "; cin >> s1.name;
cout << "enter sex: "; cin >> s1.sex;
cout << "enter age: "; cin >> s1.age;
cout << "enter date of admission: "; cin >> s1.DofAdm;
cout << "enter marks: "; cin >> s1.marks;
cout << endl;
cout << "enter details of second student" << endl << endl;
cout << "enter name: "; cin >> s2.name;
cout << "enter sex: "; cin >> s2.sex;
cout << "enter age: "; cin >> s2.age;
cout << "enter date of admission: "; cin >> s2.DofAdm;
cout << "enter marks: "; cin >> s2.marks;
cout << endl;
prntborder('*', 25);
cout << "Details for first student" << endl;
cout << "Name is: " << s1.name << endl;
cout << "Sex is: " << s1.sex << endl;
cout << "Age is: " << s1.age << endl;
cout << "Date of Admission is: " << s1.DofAdm << endl;
cout << "Mark: " << s1.marks << endl << endl;
cout << "Details for second student" << endl;
cout << "Name is: " << s2.name << endl;
cout << "Sex is: " << s2.sex << endl;
cout << "Age is: " << s2.age << endl;
cout << "Date of Admission is: " << s2.DofAdm << endl;
cout << "Mark: " << s2.marks << endl << endl << endl;
prntborder('*', 25);
return 0;
system("pause");
}
//--------------------------------------------------------
// definition for a function to make the data output pretty
// prntborder()
// function definition
void prntborder(char ch, int n)
{
cout << "STUDENTS' DATA" << endl << endl << endl;
for (int j=0; j<=n; j++)
cout << ch << endl << endl;
}
//--------------------------------------------------------
As I mentioned in the previous post the code all is not okay. Here is the output:
enter the details
enter details of first student
enter name: John
enter sex: Male
enter age: 20
enter date of admission: 25th April 2011
enter marks:
enter details of second student
[B]enter name: enter sex: enter age: enter date of admission: enter marks:[/B]
Process returned 0 (0x0) execution time : 19.798 s
Press any key to continue.
It doesn't even ask me to enter the details for the second student. Where did I go wrong? Please let me know. Thanks.
This is the border I want to display my end result in:
http://img859.images...formatiwant.jpg
I don't even know how get columns of "*" and how to increase the size of "STUDENTS' DATA" and how place it in the center at the top. Please help me.
I'm an outright beginner, learning C++. Using Win XP Pro and Code::Blocks. Be nice to me, please.:)