Can u see anything wrong?

Can u see anything wrong with this code? Visual Studio does
//Give or take iostream.. No need to point that out.
1
2
3
4
5
6
7
8
9
10
11
12
  #include <iostream>
#include <fstream>
using namespace std;
int main()
{ ifstream infile; ofstream outfile;  
infile.open(“dataFile.dat”);   
outfile.open(“out.dat”);   
int number;  
while (infile >> number)  
{ if (number > 0)outfile << number << endl; }    
infile.close();outfile.close();    return 0;   }
Last edited on
Can you tell us what errors you get? Would be helpful.
Last edited on
Error 1 error C2065: '“dataFile' : undeclared identifier
Error 3 error C2065: '“out' : undeclared identifier
Error 2 error C2228: left of '.dat”' must have class/struct/union
Error 4 error C2228: left of '.dat”' must have class/struct/union
5 IntelliSense: identifier "“dataFile" is undefined
6 IntelliSense: identifier "“out" is undefined





Last edited on
I dont see the "myFile" anywhere?
hit refresh
Have you placed the "DataFile.dat" and "out.dat" inside your project?
yes, I added it to the project and they are both in the same folder as the cpp file and they are spelt correctly
I found the wrong finally, was very hard to spot. You arent using quotations for some reason.

infile.open(“dataFile.dat”); The things around dataFile.dat is not what you want to use. You want to use these ones " "

Its the same with cout, strings etc, no idea how you messed that up
I didn't see that coming. Thanks, I have no clue how that happened.....
Haha! happens man :) Goodluck.
Did you copy the code off of a website or from a Word document? Sometimes word processors will interject these types of quotation marks automatically.
Type in word then copied/pasted to visual, so yea u are both right.
Topic archived. No new replies allowed.