Mọi người cho e hỏi làm sao để in kết quả 2 chuỗi gộp thành 1 để đưa kết quả vào file
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<fstream>
using namespace std;
struct nhanvien{
int ma,luong;
string ho,ten;
};
void nhap(nhanvien *nv,int &n)
{
fstream f;
cout<<"==============Moi nhap thong tin nhan vien==============";
cout<<endl<<"so luong nhan vien: ";
cin>>n;
f.open("D:\\input3.txt",ios::out);
for(int i=1;i<=n;i++)
{
fflush(stdin);
cout<<endl<<"ma nhan vien: ";
cin>>nv[i].ma;
f<<nv[i].ma<<endl;
fflush(stdin);
cout<<"ho nhan vien:"<<endl;
getline(cin,nv[i].ho);
f<<nv[i].ho<<endl;
fflush(stdin);
cout<<"ten nhan vien:"<<endl;
getline(cin,nv[i].ten);
f<<nv[i].ten<<endl;
fflush(stdin);
cout<<"luong nhan vien: "<<endl;
cin>>nv[i].luong;
f<<nv[i].luong<<endl;
}
f.close();
}
string luongmax(nhanvien nv[], int n)
{
int max =nv[0].luong;
int indexmax=0;
for(int i=0;i<n;i++)
{
if(nv[i].luong > max)
{
max= nv[i].luong;
indexmax = i;
}
}
string s=nv[indexmax].ho + nv[indexmax].ten;
// return nv[indexmax].ho;
}
void ghifile(nhanvien nv[],int n)
{
fstream f;
f.open("D:\\output3.txt",ios::out);
f<<"======ket qua so 2======";
f.close();
}
int main()
{
int n;
nhanvien nv[50];
nhap(nv,n);
luongmax(nv,n);
// chon(nv,n);
}
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?