Я должен написать программу для школы, которая считывает файл с плохо отформатированными именами и адресами и возвращает их в более удобной для чтения форме.
Пример: перейдите от
-john smith#165980076#8148337965#3rd и состояния st#erie#pa#16506
к
-Смит, Джон, 165-98-0076,814-833-7965,3rd & State St, Erie, PA, 16506
Указываются тип функции, имя и параметры.
#include
#include
#include
#include
using namespace std;
string fixName (string n); //takes in the name and returns it in the right format
string fixSSN (string ss); //Fixes SSN
string fixPhone(string ph); // Fixes phone number
string fixAddress(string addr); //Fixes address
string fixCity(string city); // Fixes city
string fixState(string st); // Fixes state
string extractField(string &s); //Extracts a field eg name from the input string and then deletes
//it and the octothorpe (#) that follows it. Notice string s is
//passed by reference
void buildLine(string &s, string field); // Concatenates field and a comma to string s
int main() {
string line, field;
ifstream badname;
badname.open("C:/names.txt");
if (badname.fail()) {
cout
Подробнее здесь: https://stackoverflow.com/questions/798 ... f-contacts