How to read a text file in Visual studio

Hello, as part of an exercise I wrote a piece of code to calculate some dimensions using data from a file. It worked in the lab where I was shown how to, for want of a better word, link the data file to the code I had written.

Now that I try it at home I can't remember how to do this. I guess I'm asking how I go about creating a data file.

At the moment when I run the code it says 'Cannot find or open the PDB file'. I'm using visual studio express 2013.

Any help would be greatly appreciated.


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
  // Program Frame reads input values that represent the 
// dimensions of a print from a file and calculates and 
// prints the amount of wood needed for a frame..

#include <iostream>
#include <fstream>
using namespace std;

int main ()
{  
    ifstream  din;
	ofstream dout;
    int  side;                  // vertical dimension in inches
    int  top;                   // horizontal dimension in inches
    int  inchesOfWood;          // inches of wood needed

    din.open("frame.in");
	dout.open("frame.out");
    din  >> side  >> top;
    dout  << "Dimensions are " << top  << " and "
	  << side  << "."  << endl;
    
	inchesOfWood = 2 * top + 2 * side;
    dout  << "You need "  << inchesOfWood
	  <<" inches of wood."  << endl;
	system("pause");
    return 0;
}
Last edited on
Try "clean" and "rebuild all".
Topic archived. No new replies allowed.