can you guys help me out i dont know any of the c++ functions and i dont know how to convert this tnx in advance

#include <iostream>
#include <stdlib.h>
#include <fstream>
using namespace std;

 

   struct student
   {
		 char fname[100];
		 char lname[100];
		 int id;
		 float cgpa;
   };

   int add( student * , int &);
   void displayStudents( student *, int);
   void save(student *, int);
   void load( student *, int &);


int main(int argc, char *argv[])
{
   char x;
   student info [200 ];
   int numOfStudents = 0;

   do
   {
		cout <<"============================\n";
		cout <<"			Menu			\n";
		cout <<"============================\n";
		cout <<endl;
		cout <<"={1}= Add a new student.\n";
		cout <<"={2}= Display all\n";
		cout <<"={3}= Save\n";
		cout <<"={4}= Load\n";
		cout <<"={5}= Exit\n";
		cout <<"============================\n";


		cout <<"Your Choice: ";
		cin >>x;

	   switch ( x )
	   {
			case '1' : add( info , numOfStudents  );
					   break;
			case '2' : displayStudents( info , numOfStudents);break;
			case '3' : save( info, numOfStudents);break;
			case '4' : load( info, numOfStudents);break;
			case '5' : ;break;
			default : cout <<"Invalid Choice\n";
	   }
   }while ( x  !=  '5' );

system("PAUSE");
return 0;
}

//==================================================	===

//==================================================	==========
// Add a new student to the database
int add(student * info , int & numOfStudents )
{

	if( numOfStudents < 200 )
	{
		cout << "Enter student's first name: ";
		cin >>info[numOfStudents].fname;
  
		cout << "Enter student's second name: ";
		cin >>info[numOfStudents].lname;
  
		cout <<"Enter the student id: ";
		cin >> info[numOfStudents].id;
  
		cout << "Enter the student CGPA: ";
		cin >> info[numOfStudents].cgpa; 

	  
		numOfStudents++;
	}
	else
	{
		cout << "No more room in array!" << endl;
	}

	return 0;
}
//===============================[ display ]=======================
void displayStudents( student * studentArray , int numOfStudents )
{

	  int index = 0;

	  while ( index < numOfStudents )
	  {
		   cout << "Name: "<< studentArray [ index ].fname << " " << studentArray [ index ].lname << endl;
		   cout << "ID: " << studentArray [ index ].id << endl;
		   cout << "CGPA: "<< studentArray [ index ].cgpa << endl;
		   index++;
	  }

}
//========================[ save ]=============================
void save( student * info, int numOfStudents)
{
	  int index = 0;
	  ofstream fout;
	  fout.open("datab.txt");
	  
	  fout << numOfStudents << endl;
	  
	  for( ; index < numOfStudents; ++index)
	  {
		  fout << info [ index ].fname << " " << info [ index ].lname << ' ' <<info [ index ].id << ' ' << info [ index ].cgpa << endl;
	   }	
		
		
	  fout.close();

}
//=======================[load]=================================
void load( student * info, int & numOfStudents)
{
	  ifstream fin;
	  fin.open("datab.txt");
	  
	  fin >> numOfStudents;
	  
	  int index = 0;
	  
	  while(index < numOfStudents)
	  {		  
		  fin >> info [ index ].fname >> info [ index ].lname >> info [ index ].id >> info [ index ].cgpa;
		  index++;
		}
		
		
	  fin.close();	
}

Show some effort please.
And whats wrong with not knowing the C++ functions, you are basically asking for C functions?

Replace cout with printf()

Replace cin with scanf()

Replace ofstream and ifstream with FILE*

Replace fin >> with fread() or possibly fgets(), depending on what is being read.

Replace fout << with fwrite(), or possibly fprintf(), depending on what is being written.

Edited 6 Years Ago by Ancient Dragon: n/a

heres want i have done there are too many errors can you guys help me out i dont really know how the functions in c works

#include<stdio.h>
#include <stdlib.h>

 

   struct student
   {
		 char fname[100];
		 char lname[100];
		 int id;
		 float cgpa;
   };

   int add( student * , int &);
   void displayStudents( student *, int);
   void save(student *, int);
   void load( student *, int &);


int main()
{
   FILE *pFile; 
   char x;
   student info[200];
   int numOfStudents = 0;

   do
   {
		printf("============================\n");
		printf("			Menu			\n");
		printf("============================\n");
		printf("\n");
		printf("={1}= Add a new student.\n");
		printf("={2}= Display all\n");
		printf("={3}= Save\n");
		printf("={4}= Load\n");
		printf("={5}= Exit\n");
		printf("============================\n");


		printf("Your Choice: ");
		scanf("%c",&x);

	   switch ( x )
	   {
			case '1' : add( info , numOfStudents  );
					   break;
			case '2' : displayStudents( info , numOfStudents);break;
			case '3' : save( info, numOfStudents);break;
			case '4' : load( info, numOfStudents);break;
			case '5' : ;break;
			default : printf("Invalid Choice\n");
	   }
   }while ( x  !=  '5' );

system("PAUSE");
return 0;
}

//==================================================	===

//==================================================	==========
// Add a new student to the database
int add(student * info , int & numOfStudents )
{

	if( numOfStudents < 200 )
	{
		printf("Enter student's first name: ");
		gets(info[numOfStudents].fname);
  
		printf("Enter student's second name: ");
		gets(info[numOfStudents].lname);
  
		printf("Enter the student id: ");
		scanf("%d",&info[numOfStudents].id);
  
		printf("Enter the student CGPA: ");
		scanf("%f",%info[numOfStudents].cgpa); 

	  
		numOfStudents++;
	}
	else
	{
		printf("No more room in array!");
	}

	return 0;
}
//===============================[ display ]=======================
void displayStudents( student * studentArray , int numOfStudents )
{

	  int index = 0;

	  while ( index < numOfStudents )
	  {
		   printf("Name: %s",studentArray [ index ].fname);
           printf(" "); 
           printf("%s\n",studentArray [ index ].lname);
		   printf("ID: %d\n",studentArray [ index ].id);
		   printf("CGPA: \n",studentArray [ index ].cgpa);
		   index++;
	  }

}
//========================[ save ]=============================
void save( student * info, int numOfStudents)
{
	  int index = 0;
	  pFile = fopen("student.txt", "r");
	  
	  fprintf("%d",numOfStudents);
	  
	  for( ; index < numOfStudents; ++index)
	  {
		  fprintf("%s",info[ index ].fname);  
          fprintf(" ");  
          fprintf("%s\n",info [ index ].lname); 
          fprintf("%d\n",info [ index ].id);
          fprintf("%f\n",info [ index ].cgpa);
	   }	
		
		
	  fclose(pFile);;

}
//=======================[load]=================================
void load( student * info, int & numOfStudents)
{
	  pFile = fopen("student.txt", "r");
	  
	  fread(numOfStudents);
	  
	  int index = 0;
	  
	  while(index < numOfStudents)
	  {		  
		  fread(info [ index ].fname)
          fread(info [ index ].lname)
          fread(info [ index ].id)
          fread(info [ index ].cgpa);
		  index++;
		}
		
		
	  fread.close(pFile);	
}

>> dont really know how the functions in c works
Then what you are attempting to do is waaaaayyyy over your head. Begin by learning C language -- read some tutorials and/or books. Then in a few days, or maybe a month, you will know enough to be able to fix those errors yourself.

This article has been dead for over six months. Start a new discussion instead.