| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
My emergency room
hey every body,
in my project-Emergency room Simulator- i should open file for all patient if he didnt have one, so, when the patient come, i will ask him if he has a file, if yes, i will read his information and add some more in it, if not i will open new file for him, i'll receve the patient as node of Queue, then i will write his information in a file. this is my Code, and as u see there r problem with the concatenation of these strings then put it between quotationMark Code:
void read_patient_file(Patient &patient,string fn)
{
string extention=".txt";
string file_num;
for (int d=0;d< fn.length();d++)
file_num[d]=fn[d];
string loction="C:\\";
string file_name=loction+file_num+extention;
ifstream infile;
infile.open("file_name", ios::in);
if(!infile)
{
cout<<"file could not open";
exit(1);
}
infile>>patient.name>>patient.age>>patient.gender>>patient.fileNumber>>patient.illness>>patient.degree;
infile.close();
}
Code:
void patient_file(Patient patient)
{
string file_num,extention,loction,file_name;
extention=".txt";
file_num=patient.fileNumber;
loction="C:\\pateint";
file_name=loction+file_num+extention;
ofstream ofile ("file_name", ios::out);
if(!ofile)
{
cout<<"Can't open output file";
exit(1);
}
ofile<<patient.name<<' '<<patient.age<< ' '<<patient.gender<< ' '<<patient.fileNumber<< ' '<<patient.illness<< ' '<<patient.degree;
ofile.close();
}
how could i solve this problem, and if i want to gather all patient file in One fail (patient record) how could i do it? Code:
void patient_record()//record of all patient
{
ofstream ofile ("C:\\pateint.txt", ios::out);
if(!ofile)
{
cout<<"file could not open";
exit(1);
}
ofile.close();
}
hope u can help me sooon thank u ![]() |
|
#2
|
||||
|
||||
|
Quote:
What's wrong with file_num=fn; ? Copying a standard string byte for byte is missing the whole point of using a string. And putting file_name in quotation marks anywhere makes it not refer to the variable. Quote:
We wouldn't happen to have a quote of the month award on these boards, do we? ![]() If you want to make that last file a combination of all the other files, then you will have to look up all those files, open them, and process/copy their contents, outputting it into the output file. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > My emergency room |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|