Advertisement
Guest User

Untitled

a guest
Dec 21st, 2012
157
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 <string>
  3. #include <fstream>
  4. using namespace std;
  5. int main()
  6. {
  7.      char s[254]="";
  8.      ifstream f;
  9.      ofstream f2;
  10.          
  11.     f.open("in.txt");
  12.     if (f==NULL)
  13.        {
  14.                
  15.     cout<<"file no fount :D"<<endl;
  16.     system("PAUSE");
  17.     return EXIT_SUCCESS;
  18.               }
  19.     f2.open("new.txt");
  20.      
  21.    while (!f.eof())
  22.     {
  23.          
  24.       f.getline(s, sizeof(s) );
  25.      
  26.       char *p;
  27.       p=strtok(s," ");
  28.       if (!f.eof())
  29.          f2<<p<<", ";
  30.       else
  31.          f2<<p<<"";
  32.          cout<<p<<" ";
  33.            }                  
  34.    f.close();
  35.    f2.close();
  36.  
  37.    system("PAUSE");  
  38.    return EXIT_SUCCESS;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement