Hola buenas al escribir una función de leer un fichero con datos tipo subtítulo me da un error en los getline(), y pone
error: no matching function for call to 'std::basic_ifstream<char>::getline(char [80])'
f.getline(texto);
Os dejo el programa:
void leerSubtitulos (const char nombreFichero[], Subtitulo S[]){
const int MAX_LONG_LINEA = 80;
const int MAX_LINEAS = 3;
ifstream f;
f.open(nombreFichero);
if(f.is_open()){
for(int i = 0; i<contarSubtitulos(nombreFichero); i++){
int hour,min,segs,mil_segs,numero,nLineas=0;
char aux;
Tiempo inicio,fin;
f >> numero >> hour >> aux >> min >> aux >> segs >> aux >> mil_segs;
inicio = definir(hour*3600+min*60+segs,mil_segs);
aux = f.get(); aux = f.get(); aux = f.get(); aux = f.get();; aux = f.get();
f >> hour >> aux >> min >> aux >> segs >> aux >> mil_segs;
fin = definir(hour*3600+min*60+segs,mil_segs);
f.getline();
char texto[MAX_LINEAS][MAX_LONG_LINEA];
for(int i = 0; i<MAX_LINEAS; i++){
f.getline(texto);
nLineas++;
}
S = definir(numero, nLineas, texto, inicio, fin);
}
}
else{
cerr << "No se ha podido abrir" << endl;
}
}
El método de la clase ifstream getline, según los estándares, está definido así:
istream& getline (char* s, streamsize n );
istream& getline (char* s, streamsize n, char delim );
Tiene dos sobrecargas, y ninguna coincide con la que has usado. Para solucionarlo, tienes que poner el tamaño de la cadena de caracteres como parámetro:
f.getline(texto[i], MAX_LONG_LINEA)
He deducido que deberías poner texto por el for en el que está:
for(int i = 0; i<MAX_LINEAS; i++){
f.getline(texto[i], MAX_LONG_LINEA);
nLineas++;
}