i Am beginner to c++, so bear with me
i can seem to fix these errors
error c2109
subscript requires a pointer or arrays

//Stephen Igbinedion
//CMPS
//Due Date; Dec 4th 2009
//Programming Assignments 6 (Final assignment for CMPS 1043)
//This Program orders a set of integers.

#include <iomanip>
#include <iostream>
#include <fstream>
#include <cctype>
#include <stdlib.h>

typedef int arrays[];
int arraysnumber;
void function1(arrays, int x);
void function2(arrays, arrays, arrays, int y);
void function3(arrays, int z);
using namespace std;

ifstream input;
ofstream output;


int main()
{
	 
    int arraysize;
	
	arrays unorder = {0,0,0,0,0};
	arrays index = {0,0,0,0,0};
	arrays order = {0,0,0,0,0};

	input.open("decode.txt");
	output.open("output.txt");
	output<<"ARRAYS (PROGRAMMING 6)\n\n";
	
	while(!input.eof())
	{
		input>>arraysize;
		function1(unorder, arraysize);
		function1 (index, arraysize);

		function2 (unorder, index, order, arraysize);
		
		
		output<<endl<<"unorder:            ";
		function3(unorder, arraysize);

		output<<endl<<"index:              ";
		function3(index, arraysize);
    
		output<<endl<<"order:             ";
		function3(order, arraysize);
        
		output<<endl<<endl;
	}
	output<<endl<<"----------NO      MORE        DATA--------------";
    return 0;
}

void function1(int arraysnumber,int arraysize)
{
	for (int j = 0; j < arraysize; j++)
	{
		input>>arraysnumber[arraysize];
	}
}

void function2(arrays unorder, arrays index, arrays order, int arraysize)
{
	for (int j = 0; j<arraysize; j++)
	{
		order[index[j]]=unorder[j];
	}
}

void function3(int arraysnumber, int arraysize)
{
	for( int j = 0; j < arraysize; j++)
		output<<arraysnumber[arraysize]<<endl;
}

Recommended Answers

All 5 Replies

edit your post to include code tags [code] // your code goes here [/code]

where (which line) does the error occur?

it occurs at outfile<<arraysnumber[j]<<'\t'; 81

and the error also occurs at

infile>>arraysnumber[j]; line 73

//Stephen Igbinedion
//CMPS
//Due Date; Dec 4th 2009
//Programming Assignments 6 (Final assignment for CMPS 1043)
//This Program orders a set of integers.

#include <iomanip>
#include <iostream>
#include <fstream>
#include <cctype>
#include <stdlib.h>

typedef int arrays[];
int arraysnumber;
void function1(arrays, int x);
void function2(arrays, arrays, arrays, int y);
void function3(arrays, int z);
using namespace std;

ifstream infile;
ofstream outfile;


int main()
{
	 
    int arraysize;
	
	arrays unorder = {0,0,0,0,0,0,0,0,0,0};
	arrays index = {0,0,0,0,0,0,0,0,0,0};
	arrays order = {0,0,0,0,0,0,0,0,0,0};

	infile.open("decode.txt");
	outfile.open("output.txt");
	outfile<<"ARRAYS (PROGRAMMING 6)\n\n";
	
	while(!infile.eof())
	{
		infile>>arraysize;
		function1(unorder, arraysize);
		function1 (index, arraysize);

		function2 (unorder, index, order, arraysize);
		
		
		outfile<<endl<<"unorder:            ";
		function3(unorder, arraysize);

		outfile<<endl<<"index:              ";
		function3(index, arraysize);
    
		outfile<<endl<<"order:             ";
		function3(order, arraysize);
        
		outfile<<endl<<endl;
	}
	outfile<<endl<<"----------NO      MORE        DATA--------------";
    return 0;
}

void function1(int arraysnumber,int arraysize)
{
	for (int j = 0; j < arraysize; j++)
	{
		infile>>arraysnumber[j];
	}
}

void function2(arrays unorder, arrays index, arrays order, int arraysize)
{
	for (int j = 0; j<arraysize; j++)
	{
		order[index[j]]=unorder[j];
	}
}

void function3(int arraysnumber, int arraysize)
{
	for( int j = 0; j < arraysize; j++)
	{
	outfile<<arraysnumber[j]<<'\t';
}

arraysnumber is not an array; its just a single integer. YOu need to declare the parameter something like this: void function3(int arraysnumber[], int arraysize) so that the compiler knows it's an array.

Thanks ancientdragon........... everything works perfectly fine
Thanks for your time.........

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.