Need help with infile/outfile

Need help understanding how to read numbers from a text file, and square rooting those numbers to an outfile. Had missed class today and am utterly lost.

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
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;

int main()
{
	char fileName;
	double number = 0;
	
	cout << "Enter an input file name:  ";
	cin >> fileName;


	ifstream inFile;
	ofstream outFile;

	switch  (fileName)
		case 'A': inFile.open("C:\\Users\\Josh\\Desktop\\numbers\\a.txt");
		outFile.open("C:\\Users\\Josh\\Desktop\\numbers\\squareroots.txt");

		inFile >> number;

		while (inFile)
		{
			sqrt(number);
			inFile >> number;
			outFile << number;
		}
		inFile.close();
		outFile.close();
	switch(fileName)
		case 'B': inFile.open("C:\\Users\\Josh\\Desktop\\numbers\\b.txt");
		outFile.open("C:\\Users\\Josh\\Desktop\\numbers\\squareroots.txt");

		inFile >> number;

		while (inFile)
		{
			sqrt(number);
			inFile >> number;
			cout << number;
		}
		inFile.close();
		outFile.close();
		
	if(fileName = 'C') 
		
		inFile.open	("C:\\Users\\Josh\\Desktop\\numbers\\c.txt");
		outFile.open("C:\\Users\\Josh\\Desktop\\numbers\\squareroots.txt");

		inFile >> number;

		while (inFile)
		{
			sqrt(number);
			inFile >> number;
			cout << number;
		}
		inFile.close();
		outFile.close();
		

	return 0;
}

The following program:
http://coliru.stacked-crooked.com/a/30a522fe9a571f3c
... was tested on the .txt file:
9 14 3 9 19 7 6 5 8 1

If your file is formatted differently of course you'll have to make the necessary adjustments to the program
Can someone also help me?
I have an exam tomorrow and I am required to read numbers from a text file that is already created and store it in a new text file that I have to create using code.

Create a notepad file called "rawmarks.txt" and store it in your Visual studio project folder. Populate it manually with data (ID, Course code, Marks). You are required to write C++ code to read in the values from the text file, process the data and create a summary file called "processedmarks.txt".
Topic archived. No new replies allowed.