Trouble with getting program to function properly

So this program will compile, but I cannot get it to print out anything so i do not know if it's doing what i intend. I'm trying to get it to convert text from a file ("mystery.txt"), such that uppercase goes to lowercase, lowercase to uppercase, punctuation characters to digits and special characters to ASCII characters. I also need to count:
the total number of characters in the file
the number of alphabetic characters
the number of uppercase alphabetic characters
the number of lowercase alphabetic characters
the number of digits
the number of punctuation marks
the number of newline characters
the number of spaces

Can anyone point me in the right direction? Here's my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#include<iostream>
#include<iomanip>
using namespace std;

//FUNCTION PROTOTYPES:
char convUpperToLower(char);
char convLowerToUpper(char);
char convPunct(char);
char convSpecial(char);

int main()
{
    ifstream inFile;

char ch;

inFile.open( "mystery.txt" )
if( inFile.fail() )
  {
  cout << "Input file failed to open";
  exit(-1);
  }

inFile >> ch;

while (inFile)
  {
  if(isupper(ch))
  {
  ch = convUpperToLower(ch);
  return ch;
  }
  if(islower(ch))
  {
  ch = convLowerToUpper(ch);
  return ch;
  }
  if(ispunct(ch))
  {
  ch = convPunct(ch);
  return ch;
  }
  if(isdigit(ch))
  {
  ch = convPunct(ch);
  return ch;
  }
  if(isalpha(ch))
  {
  ch = convSpecial(ch);
  return ch;
  }
  //Display the decoded character

  inFile >> ch;
  }

inFile.close();
    
    system("pause");
    return 0;
}
char convUpperToLower(char ch)
{
     char newch;
     tolower(char ch); //conv lower
     newch = ch-3; //subtracts 3
     if(ch == "A")
     {
           newch = "x";
     }
     if(ch == "B")
     {
           newch = "y";
     }
     if(ch == "C")
     {
           newch = "z";     
     }
     return newch;
}
char convLowerToUpper(char ch)
{
     char newch;
     toupper(char ch);
     newch = ch+3;
     if(ch == "x")
     {
           newch = "A";
     }
     if(ch == "y")
     {
           newch = "B";
     }
     if(ch == "z")
     {
           newch = "C";     
     }
     return newch;
     
}
char convPunct(char ch)
{
     char newch;
     if(ch == ")")
     {
           newch = "0";
     }
     else if(ch == "!")
     {
           newch = "1";
     }
     else if(ch == "@")
     {
           newch = "2";
     }
     else if(ch == "#")
     {
           newch = "3";
     }
     else if(ch == "$")
     {
           newch = "4";
     }
     else if(ch == "%")
     {
           newch = "5";
     }
     else if(ch == "^")
     {
           newch = "6";
     }
     else if(ch == "&")
     {
           newch = "7";
     }
     else if(ch == "*")
     {
           newch = "8";
     }
     else if(ch == "(")
     {
           newch = "9";
     }
     else if(ch == ">")
     {
           newch = ".";
     }
     else if(ch == "<")
     {
           newch = ",";
     }
     else if(ch == "/")
     {
           newch = "?";
     }
     else if(ch == ";")
     {
           newch = "!";
     }
     else if(ch == "+")
     {
           newch = "(";
     }
     else if(ch == "=")
     {
           newch = ")";
     }
     return newch;
}
char convSpecial(char ch)
{
     cout << "idk";
}


Thanks!
Derek
Last edited on
Use single quotes for characters ' not ".

Also #include <fstream>.

There are a few other bugs, but that should get you started cleaning them up.
Topic archived. No new replies allowed.