Where is the namespace std after cin? You have to use std::cin if you don't directly state that you are 'using namespace std'. And also, where is your include statement, cin is located in the iostream header!
#include <iostream>
#include <string>
#include <fstream>
int main()
{
std::string filename, contents = "";
std::cin >> filename;
std::ifstream if(file);
while(std::getline(if, contents))
contents += contents + "\n";
//do something with contents
} I am pretty new to C++ but I think this should compile and work.