-
Question
Hi everyone.
I am new to this board and new to programming as well.
The scenario is that
I am having to read lines of text (unknown lines) from external file and I need to sort them in alphabetical order ( lines consist of last name, first name, and jobtitle) and write to a different external file.
I am not allowed to use strings array but I am allowed to use
strcpy, strlen, strcomp etc..
I will read the first line as character array.
store character array to other variable array(?)
then I am lost. I think it's possible to use array of array?
Any help is greatly appreciated.
Thanks.
-
Post the code that you have so far.
-
#include <fstream.h>
int main ()
{
ifstream in;
ofstream out;
char str[];
char line[];
// Open the files
in.open ("cd.dat");
out.open ("prog5.data");
// Get data
while (!in.eof())
{
char str [81];
in.get (str, 80, '\n');
in.get ();
length = strlen (str);
for (int i=0; i<length; i++)
{
strcpy (line[i], str[i]);