Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.  
  9. ifstream fin;
  10. fin.open("test4.cpp", ios::in);
  11.  
  12. char start_char ;
  13. string define_name;
  14. string defined_value;
  15.  
  16. while (!fin.eof() )
  17. {
  18. fin.get(start_char);
  19.  
  20.  
  21.  
  22. if(start_char == '#')
  23. {
  24. fin.get(start_char);
  25. cout<<start_char;
  26.  
  27. if(start_char == 'd')
  28. {
  29. while(start_char != ' ')
  30. {
  31. fin.get(start_char);
  32. cout<<start_char;
  33. }
  34.  
  35. fin.get(start_char);
  36. cout<<start_char;
  37.  
  38. while(start_char != ' ')
  39. {
  40. define_name += start_char;
  41. fin.get(start_char);
  42. cout<<start_char;
  43. }
  44.  
  45. fin.get(start_char);
  46. cout<<start_char;
  47.  
  48. while(start_char != ' ' && start_char != '\n')
  49. {
  50. defined_value += start_char;
  51. fin.get(start_char);
  52. cout<<start_char;
  53. }
  54.  
  55. cout << "Definition name: " + define_name << endl;
  56. cout << "Defined Value: " + defined_value << endl;
  57. }
  58. }
  59.  
  60. for(int i = 0; i < define_name.length(); i++)
  61. {
  62. if(start_char == define_name[i])
  63. {
  64. fin.get(start_char);
  65.  
  66. if(start_char == define_name[i+1])
  67. {
  68. cout << defined_value << endl;
  69.  
  70. fin.get(start_char);
  71. }
  72. }
  73. }
  74. cout<<start_char;
  75. }
  76.  
  77.  
  78. std::getchar();
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement