Guest User

Untitled

a guest
Nov 16th, 2011
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <cctype>
  4. #include <string>
  5. #include <fstream>
  6. using namespace std;
  7.  
  8.  
  9.  
  10. void openFile(ifstream& ins);
  11. int shiftMod(char shift);
  12. char punctCheck(char c);
  13.  
  14. int main ()
  15. {
  16. int shiftvalue = 0;
  17. char shift;
  18. char c;
  19. ifstream ins;
  20. openFile(ins); //Opens file and prints out error if file doesn't exist.
  21. while (!ins.eof()) //Will continue to run code until end of file.
  22. {
  23.  
  24. if(ispunct(c)) //Checks if character is punct.
  25. {
  26. if(c == '.' || c == ','|| c == ':' || c == '!' || c == '\'') //If c is something normal, it just prints it out.
  27. {
  28. cout << c;
  29. }
  30. if(c == '>' || c == '<')
  31. {
  32. c = shift;
  33. shiftMod(shift);
  34. }
  35. if (c == '#')
  36. {
  37. }
  38. if(c == '+' || c == '-')
  39. {
  40. }
  41.  
  42. }
  43. if (isalpha(c)) //Checks if character is an alpha. NEED TO ADD THE SHIFT THING
  44. {
  45. char ch = c;
  46. toupper(ch);
  47. cout << ch;
  48. }
  49. }
  50.  
  51. return 0;
  52.  
  53. }
  54.  
  55.  
  56. int& shiftMod(char& shift)
  57. {
  58. if (c == '>')
  59. {
  60. char shiftnumber = cin.peek();
  61. if (isdigit(shiftnumber))
  62. {
  63. int holder = 0;
  64. char temp = shiftnumber;
  65. holder = atoi(&temp);
  66. }
  67.  
  68. }
  69. if (c == '<')
  70. {
  71. }
  72. }
  73.  
  74.  
  75.  
  76.  
  77.  
  78. void openFile(ifstream& ins)
  79. {
  80. string fileName;
  81. cout << "Enter filename (with extension): ";
  82. cin >> fileName;
  83. ins.open(fileName.c_str());
  84. while (!ins)
  85. {
  86. ins.clear();
  87. cout << "*** ERROR: Error in opening file ***"
  88. << endl << "You entered an invalid file name. Please try again." << endl <<endl;
  89. cout << "Enter filename (with extension): ";
  90. cin >> fileName;
  91. ins.open(fileName.c_str());
  92. }
  93. }
  94.  
Advertisement
Add Comment
Please, Sign In to add comment