Advertisement
Guest User

Untitled

a guest
May 1st, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <ostream>
  4. #include <windows.h>
  5.  
  6. /*
  7.     Letter (Letter | Digit)*
  8. */
  9.  
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14.     fstream text("D:\\text.txt");
  15.  
  16.     if (!text)
  17.     {
  18.         cout << "Error!\n";
  19.         exit(-1);
  20.     }
  21.  
  22.     char in;
  23.     string var_name;
  24.     in = text.get();
  25.     cout << "in = " << in << endl;
  26.  
  27.     if (isalpha(in))
  28.     {
  29.         var_name += in;
  30.         cout << "var_name = " << var_name << endl;
  31.     }
  32.     else
  33.     {
  34.         cout << "Error!\n";
  35.         exit(-1);
  36.     }
  37.  
  38.     in = text.get();
  39.     cout << "second in = " << in << endl;
  40.  
  41.     while ((isalpha(in) || isdigit(in)) && (!text.eof()))
  42.     {
  43.         var_name += in;
  44.         in = text.get();
  45.         cout << "\nin = " << in;
  46.     }
  47.  
  48.     cout << "\nvar_name = " << var_name << endl;
  49.     text.close();
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement