Hi i have a binary function search program where the user enters a index of numbers, then enters the number he wants to find. However my program wont compile and says the subscripted value is neither an array or pointer. Help me out please. Here is what ive got:

# include <stdio.h>
# include "genlib.h"
# include "simpio.h"
# include "stdlib.h"
# include "strlib.h"
# define c 33000


int bisearch(int nArray,int arraynum, int maxarray)
{
     int ran,track,sort,sort2,num1,save,count,result;
     count=0;
     sort=arraynum;
     sort2=sort;
     while(num1!=0)
     printf("whats the next integer");
     num1=GetInteger();
     {
     nArray[arraynum]=GetInteger();
     while(sort!=0)
     if(nArray[arraynum]<nArray[arraynum-1])
                 {
     num1=nArray[arraynum-1];
     nArray[arraynum-1]=nArray[arraynum];
     nArray[arraynum]=num1;
     sort=sort-1;
     arraynum=arraynum-1;
                 }
else
      {
     sort=sort-1;
      }
     arraynum=sort2;
     sort2=sort2+1;
     sort=sort2;
     printf("%d",nArray[arraynum]);
     arraynum=arraynum+1;
     count=count+1;
     }
     printf("what is your number");
     
     while(count!=0)
     {
     if(result==nArray[arraynum])
     {
     printf("the number is in index %d",arraynum);
     break;
     }
else
     {
     arraynum=arraynum-1;
     count=count-1;
     }
}
     
     
     
main()
{
      int maxarray,arraynum,bin;
      printf("whats is are the numbers you want for your index. Hit 0 to end.");
      int nArray[c];
      nArray[arraynum]=0;
      arraynum=0;
      bin=bisearch(arraynum,maxarray,nArray[arraynum]);
      getchar();
}

Code terrible. It is difficult to even understand what you are trying to do. Opening bracket itself:) ... there are no closing parenthesis ...

# include "genlib.h"
# include "simpio.h"
# include "strlib.h"

is that the header files?

If you have an error message please...please copy it down and pass it on to us...

you have to figure out that nArray is local to the main method.
you can't access nArray inside you're bisearch method. So that is the
problem.

Looks like you new to C++ , I suggest you to read a free book on C++ first at least variable scope chapter.
http://en.wikibooks.org/wiki/C%2B%2B_Programming/Scope

After reading this , I think you can point where is the wrong.

These does not seem to be a header file code:
# include "genlib.h"
# include "simpio.h"
# include "stdlib.h"
# include "strlib.h"
Try to replace the "" with <> The error may be fixed.

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.