Reputation: 1
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <iomanip>
using namespace std;
#define ARRAYSIZE 15;
int main(void)
{
//things needed
ifstream infile;
ofstream outfile;
double xArray[ARRAYSIZE];
}
As you can see, my code should be in order but my program keeps telling me it expects a '[' where the xArray[ARRAYSIZE] is. By the way I'm using microsoft visual studio 2013.
Upvotes: 0
Views: 461
Reputation: 672
#define ARRAYSIZE 15;
Define will substitute ARRAYSIZE with whatever is there next to it.
So in this case it will substitute ARRAYSIZE
with 15;
So all you need to do is just remove the semi-colon in the define statement
Upvotes: 0
Reputation: 46598
after preprocess, your code is kind of
int main(void)
{
//things needed
ifstream infile;
ofstream outfile;
double xArray[15;]; // replace ARRAYSIZE with 15;
}
so you have to remove ;
in #define
#define ARRAYSIZE 15
Upvotes: 0
Reputation: 62062
#define ARRAYSIZE 15
Take the ;
out of the #define
.
With your #define
written as is,
double xArray[ARRAYSIZE];
translates to
double xArray[15;];
The compiler expects a ]
before the first ;
.
Doing this:
const int ARRAYSIZE 15;
might be better...
Upvotes: 2