Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- using namespace std;
- int main(int argc, char *argv[])
- {
- char a[251];
- char b[251];
- {
- ifstream ifile;
- ifile.open("virkne3.in", ifstream::in);
- if( !ifile.is_open( )) {
- cout << "Nevar atvert failu virkne3.in" << endl;
- system("PAUSE");
- return 255;
- } else {
- cout << "Fails atverts veiksmiigi" << endl;
- }
- while(ifile.good()) {
- ifile >> a;
- cout <<"Ievadiitaa fraaze: "<< a << endl;
- }
- }
- char last = '0';
- int tpos = 0;
- for(unsigned int i = 0; i < strlen(a); i++)
- {
- if( (last != a[i]) ) { b[tpos++] = a[i]; last = a[i]; }
- }
- b[tpos] = '\0';
- cout << "Labojums:" << b << endl;
- {
- ofstream myfile ("virkne3.out");
- if (myfile.is_open())
- {
- myfile << b;
- cout << "Labojums veiksmigi ievadiits faila virkne3.out" <<endl;
- myfile.close();
- }
- else cout << "Nevar atvert failu.";
- }
- system("PAUSE");
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement