for (int d=0;d< fn.length();d++)
file_num[d]=fn[d];
Why not just use the assignment operator ? No need for that loop file_num = fn;
>>string file_name=loction+file_num+extention;
That is a little odd. Why not use the fd parameter and delete the loop quoted above ? string file_name=loction+fn+extention;
>>ofstream ofile ("file_name", ios::out);
Remove the quotes. Also delete ios::out because that's the default for ofstream ofstream ofile (file_name.c_str());
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
how could i arrange the output?
Use double quotation marks " " instead of ' ', for example;
ofile<<patient.name<<<strong>" "</strong><<patient.age<< <strong>" "</strong> <<patient.gender<< <strong>" "</strong> <<patient.fileNumber<< <strong>" "</strong> <<patient.illness<< <strong>" "</strong> <<patient.degree;
You can choose the length of the string as you wish.
>> but what if i want to gather all files in One file, how could i do it?
Write that file so that a single line of the file contains all data of a single patient.
mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
about .c_str() what it does?
It returns a "const char *", a pointer to a null-terminated C-style string that the std::string internally holds. You should not modify the memory pointed by the pointer you get from calling c_str() i.e. consider it as read-only.
string str = "testing";
const char * ptr = str.c_str();
// the following prints out: testing
cout << ptr;
Here is one reference for std::string http://www.cplusplus.com/reference/string/string/
mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395