0

Necesito ayuda con este codigo me da un error en al linea 49

#include <iostream> #include <string> #include <vector> #include <stdlib.h> using namespace std; vector<string> ajuste_linea(string entrada, size_t limite) { vector<string> lineas; size_t i = 0; size_t p = 0; long it = 0; size_t full_length = entrada.length(); while (i < full_length) { string linea; while (true) { i = entrada.find(' ', p); if (i != string::npos) { if ((i-p) + linea.length() <= limite) { linea += entrada.substr(p, i-p+1); p = i+1; } else break; } else { linea += entrada.substr(p); break; } } lineas.push_back(linea); } return lineas; } int main() { char texto[100]; size_t limite; cout << "Introduzca el texto a ajustar:> "; cin.getline(texto,100); cout << "\nIntroduzca el limite de linea:> "; cin >> limite; vector<string> ajustado = ajuste_linea(texto, limite); cout <<"\n"<< endl; for (auto it = ajustado.begin(); it != ajustado.end(); ++it) { cout << *it << endl; } system("PAUSE"); return 0; }

9th Apr 2020, 10:13 PM
Gelhpiz Hernandez
Gelhpiz Hernandez - avatar
1 Odpowiedź
+ 1
I do not get an error on line 49. When SoloLearn prompts you for input, it prompts for all input values only once per run. You must type the string and press Enter key, then type the length and then press Submit.
9th Apr 2020, 10:50 PM
Brian
Brian - avatar