Advertisement
eimkasp

C++ Spliting String (Testas 17)

Jan 28th, 2012
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string.h>
  4. #include <string>
  5. #include <locale.h>
  6.  
  7. using namespace std;
  8.  
  9. string zodz[50];
  10.  
  11. int main() {
  12.     int i = 0;
  13.     char a[256];
  14.     int n;
  15.     //char zodis[];
  16.     string temp;
  17.     char * split;
  18.     ifstream fd("Duomenys.txt");
  19.     ofstream fr("Rezultatas.txt");
  20.     fd.getline(a,256);
  21.     cout << a << endl;
  22.     split = strtok(a," ,.-");
  23.  
  24.    
  25.     cout << "Iveskite zodzio vieta ";
  26.     cin >> n;
  27.     cout << endl;
  28.     cout << "Iveskite zodi ";
  29.     cin >> temp;
  30.  
  31.     while (split != NULL) {
  32.         i++;
  33.         if ( i == n) {
  34.             fr << temp << " "; 
  35.             cout << temp << " ";
  36.         }
  37.         printf ("%s\n",split);
  38.         fr  << split << " ";
  39.         split = strtok (NULL, " .-");
  40.      }
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement