Hello
I have an array in a function that I am trying to copy into a private array named pic_links although I am getting an error, it wont let me copy the array into another array.
Do you know why? :)
Error message:
no matching function for call to `strcpy(std::string[299], std::string[299])'
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <string>
using namespace std;
class generate_post {
public:
void read(char* filename, int& counter);
void random(int array[], int max);
void create_post( int& counter);
void record_used_pics();
private:
string pic_links[299];
string used_pic[299];
string post[6];
int random_p[6];
};
int main() {
int pic_count = 0;
generate_post html;
html.read("pic_links.txt",pic_count);
html.create_post(pic_count);
html.record_used_pics();
return 0;
}
void generate_post::read(char* filename, int& counter) {
char x;
string pic_array[299];
ifstream infile;
infile.open(filename);
if (!infile) {
cout << "Failed to open file";
}
while (infile >> x) {
if (x=='m') {
getline(infile,pic_array[counter],'\n');
counter++;
}
}
infile.close();
counter = counter-1;
strcpy(pic_array,pic_links); // error occurs here
}