Guys, in this program, we have a file by the name of asharray.txt, which is attached to this post, and we have three functions:
1.to read the file
2.to sort the numbers
3.to write to a separate file by the name of( array result.txt)
Sp, here I faced some problems, in the third function and I am not able to figure it out, so guys anyone who can resolve ma doubt..............

#include <cstdlib>
#include <iostream>
#include <fstream>

using namespace std;
void fileread(int array[],int &counter)
{
     ifstream fin;
     counter=0;
     int number;
     fin.open("asharray.txt");
     if(fin.fail())
     {
      cout<<" The file dose not exist " << endl;
      system("PAUSE");
     }
      while(!fin.eof())
      {
       counter ++;
       fin>>array[counter];
       if(fin.fail())
       {
        cout<<" There is some error with the variable declaration "<< endl;
        system("PAUSE");
       }
      }
      fin.close();
}

void sorting(int array[], int size)
{
    int i,j;
    int temp;
    for(i=0;i<size;i++)
    {
     for(j=i+1;j<size;j++)
     {
      if(array[i]<array[j])
      {  
         temp=array[i];
         array[i]=array[j];
         array[j]=temp;
      }
     }
    }
    cout<< " THE SORTED ARRAY ARE " << "array [" << i <<"] = " << array[i] << endl;
}
void writetofile(int array[],int size)
{
 ofstream fout();
 int i;
 fout.open("array result.txt");// error request for member `open' in `fout', which is of non-class type `std::ofstream ()()' 
 fout<<" The sorted array is "<< endl;
 for(i=0;i<size;i++)
 {
  fout<<array[i];
 }
}
 

int main(int argc, char *argv[])
{
    int size=10;
    system("PAUSE");
    return EXIT_SUCCESS;
}

Guys, in this program, we have a file by the name of asharray.txt, which is attached to this post, and we have three functions:
1.to read the file
2.to sort the numbers
3.to write to a separate file by the name of( array result.txt)
Sp, here I faced some problems, in the third function and I am not able to figure it out, so guys anyone who can resolve ma doubt..............

I doubt it.

You've been asked to provide details before.

Since we don't know what you are having problems with, we cannot provide suggestions. As mentioned before, we cannot read your mind.

I am having problem with line 52

I am having problem with line 52

Why? Does it not compile? Does it operate wrong? Does it threaten to blow up Japan?

Do you know what details are? From here:

1. an individual or minute part; an item or particular.
2. particulars collectively; minutiae.
9* to relate or report with complete particulars; tell fully and distinctly.
10* to mention one by one; specify; list: He detailed the events leading up to the robbery.
13* in detail, item by item; with particulars: The résumé stated his qualifications in detail.

lol, ths poor code, can't threaten nyone, I don't know, why, but can you check my code, is it correct or wrong.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.