Lowercase to uppercase using ASCII

Hi

Here I'm trying to load a coded message from a text file to decode it using ASCII.

I take the first letter in the text file which is h and pass it to ch but then when I run a test h doesn't seem to be passed to "message" through "changeLower"

How can I fix it ?

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
#include <iostream>
#include <iomanip>
#include <fstream> // for ifstream infile;
#include <ctype.h>

using namespace std;


//Functions***********************************************

bool isspecial( char ch){
    
    char special1;
    char special2;
    
    ch = special1;
    
    if (special1 == 22) {
        
        special2 = 32;; //Space in ASCII
    }
    
    return special2;
}


char changeLower( char ch){
    
    char lowertoupper1;
    char lowertoupper2;
    
    ch = lowertoupper1;
    
    lowertoupper2 = (lowertoupper1 - 31);
    return lowertoupper1;
    
}

char changeUpper( char ch){
    
    char uppertolower1;
    char uppertolower2;
    
    ch = uppertolower1;
    
    uppertolower2 = uppertolower1 + 31;
    return uppertolower2;
    
    
}
/*

char changePunct( char ch){
    
    
    
    
    
    
}

char changeSpecial( char ch){
    
    
    
    
    
    
}
 */

//End************************************************************


int main(){
    
    char ch; //To copy info. from the text file
    char message = 'f'; //The decoded message
    
    ifstream infile;
    //input file stream variable
    //this will be used instead of cin
    
    infile.open( "/Users/ha/Desktop/Desktop/NIU/CSCI 240/Program 6/encoded_quotes.txt" );    //open the file for reading
    
    
    
    //if the input file failed to open--------------------
    if( infile.fail() )
    {
        cout << "input file did not open" << endl;
        exit(-1);                //stop execution of the program immediately
    }
    
    
    //Read the first character-----------------------------
    infile >> ch;
    
    
    
    
    //While there still data in the file-------------------
   //while (infile) {
        
        
    
        if (islower(ch)) {
            
            message = changeLower(ch);
            
            cout << message;
            
            
            
            
        }
        
        
   //}
    
    
    infile.close();
    
    
    
}


Last edited on
Your answer didn't help but I figured it out.
Thanks anyway
Topic archived. No new replies allowed.