I am beginner, please check my code,errors come during compiling.
#include <iostream>
#include <conio.h>
#include <string>
#include <iomanip>
using namespace std;
struct Course{
string course;
string coursename;
string coursecode;
string semesters;
string year;
};
void InputCourse();
void FormateCourse();
void DisplayHeaders();
void DisplayCourse();
void input_Course()
{
int i=0;
while(i <=5)
{
cout <<"Enter Course Code alang with Course Name: ";
getline( cin, Course.course );
stringstream ss( Course.course );
ss >> Course.coursecode;
getline( ss, Course.coursename );
name = trim( Course.coursename );
cout << "Enter Semester with Year :" ;
getline( cin, Course.course );
stringstream ss( Course.course );
ss >> Course.semesters ;
getline( ss, Course.year );
name = trim( Course.year );
i++;
}
}
void DisplayHeaders()
{
cout<<"\n# Course Code \t\t Course Name \t\t Semester\tLounching Year"<<endl;
cout<<"\n--------------------------------------------------------------------------------\n"<<endl;
}
void FormateCourse()
{
cout <<Course.coursecode<<"-"<<Course.coursename<<"-"<< Course.semesters, Course.year<<course.year<<"-"<<Course.year<<endl;
}
void DisplayCourse()
{
for(int i= 0;i<5; i++)
{
std::cout.width(1); std::cout << std::right << i+1<<" ";
std::cout.width(6); std::cout << std::right << Course.coursecode<<"\t";
std::cout.width(30); std::cout << std::right << Course.coursename << "\t";
std::cout.width(12); std::cout << std::right << Course.semesters,Course.year<< "\t";
std::cout.width(4); std::cout << std::right << Course.year<< endl;
}
}
int main()
{
InputCourse();
DisplayHeaders();
DisplayCourse();
getch();
}
Last edited on