I'm trying to create something similar to string.find
with vectors c++98
, but I can't fix this error.
I have simplified the code and left only the error.
If I can get help on how to achieve this.
#include <iostream>
#define MAX 99999
using namespace std;
int free_pos (int v[]);
int find_line (int v[], int pos);
int main() {
char text[MAX];
int loc_key[MAX],start_line[MAX]; //
for(int i=0; i<free_pos(loc_key);i++) {
cout << "Line: " << i+1;
int pos = find_line(start_line[],loc_key[i]); //Here is the error
for(int j=start_line[pos];j<start_line[pos+1];j++) {
cout<<text[j];
}
cout<<endl;
}
return 0;
}
int free_pos (int v[]) {
for(int i=0;i<MAX;i++){
if(v[i] == 0)
return i;
}
return 99;
}
int find_line (int v[], int pos) {
for(int i=0; i<free_pos(v); i++) {
if(v[i]==pos)
return v[i];
if(v[i]< pos)
return v[i-1];
}
}