C++ Confusion.  Reading Integer From Text File.  Convert to ASCII
I am learning C++ for the first time.  I have no previous programming background.

In the book I have I saw this example.

    #include <iostream>
    
    using::cout;
    using::endl;
    
    int main()
    {
    	int x = 5;
    	char y = char(x);
    
    	cout << x << endl;
    	cout << y << endl;
    
    	return 0;
    }

The example makes sense: print an integer and the ASCII representation of it.

Now, I created a text file with these values.

    48
    49
    50
    51
    55
    56
    75

I am writing a program to read this text file -- "theFile.txt" -- and want to convert these numbers to the ASCII value.

Here is the code I wrote.


    #include <iostream>
    #include <fstream>
    
    using::cout;
    using::endl;
    using std::fstream;
    
    int main()
    {
    	ifstream thestream;
    	thestream.open("theFile.txt")
    
    	char thecharacter;	
    
    	while (thestream.get(thecharacter))
    	{
    		int theinteger = int(thecharacter);
    		char thechar = char(theinteger);
    		cout << thechar << endl;
    	}
	return 0;
    }

This is my understanding about the second program shown.

- The compiler does not know the exact data type that is contained in "theFile.txt".  As a result, I need to specify it so I choose to read the data as a char.
- I read the each digit in the file as a char and converted it to an integer value and stored it in "theinteger". 
- Since I have an integer in "theinteger" I want to print it out as a character but char thechar = char(theinteger); does not work as intended.

What am I doing incorrect?
C++ Confusion.  Reading Integer From Text File.  Convert to ASCII
===

I am learning C++ for the first time.  I have no previous programming background.

In the book I have I saw this example.

    #include <iostream>
    
    using::cout;
    using::endl;
    
    int main()
    {
    	int x = 5;
    	char y = char(x);
    
    	cout << x << endl;
    	cout << y << endl;
    
    	return 0;
    }

The example makes sense: print an integer and the ASCII representation of it.

Now, I created a text file with these values.

    48
    49
    50
    51
    55
    56
    75

I am writing a program to read this text file -- "theFile.txt" -- and want to convert these numbers to the ASCII value.

Here is the code I wrote.


    #include <iostream>
    #include <fstream>
    
    using::cout;
    using::endl;
    using std::fstream;
    
    int main()
    {
    	ifstream thestream;
    	thestream.open("theFile.txt")
    
    	char thecharacter;	
    
    	while (thestream.get(thecharacter))
    	{
    		int theinteger = int(thecharacter);
    		char thechar = char(theinteger);
    		cout << thechar << endl;
    	}
	return 0;
    }

This is my understanding about the second program shown.

- The compiler does not know the exact data type that is contained in "theFile.txt".  As a result, I need to specify it so I choose to read the data as a char.
- I read the each digit in the file as a char and converted it to an integer value and stored it in "theinteger". 
- Since I have an integer in "theinteger" I want to print it out as a character but char thechar = char(theinteger); does not work as intended.

What am I doing incorrect?