Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <fstream>
- #include <string.h>
- #define fileR argv[1]
- using namespace std;
- FILE *f;
- const int fw = 5;
- int main(int argc, char* argv[])
- {
- char q[5][255];
- setlocale(LC_ALL, "Russian");
- if (argc < 2) {
- cout << "Недостаточно аргументов";
- exit(1);
- }
- FILE *f = fopen(fileR, "r");
- if (f == NULL) {
- system("cls");
- cout << "Файла не существует.\n\n"; // Вывести сообщение о успехе создания?
- exit(1);
- }
- int i, j;
- for (i = 0;i < fw;i++) fscanf(f, "%s", &q[i]);
- fclose(f);
- int maxlen = 0;
- for (i = 0;i < 5;i++) {
- cout << q[i] << endl;
- if (strlen(q[i]) > maxlen) maxlen = strlen(q[i]);
- }
- cout << "Максимальная длина строки: " << maxlen << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement