Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <cctype>
- #include <vector>
- using namespace std;
- void readFile(string);
- class info {
- public:
- int rows;
- int cols;
- vector < string > data;
- };
- int main(int argc, char **argv){
- string filename1;
- filename = argv[1];
- readFile(filename);
- return 0;
- }
- //should read onle line at a time from a file and print it
- void readFile(string filename1){
- fstream datafile;
- datafile.open(filename1);
- while (!datafile.eof()){
- string line;
- getline(datafile,line);
- cout<<line<<endl;
- }
- datafile.close();
- }
- project2.cpp: In function ‘int main(int, char**)’:
- project2.cpp:22:2: error: ‘filename’ was not declared in this scope
- filename = argv[1];
- ^
- project2.cpp: In function ‘void readFile(std::string)’:
- project2.cpp:32:25: error: no matching function for call to ‘std::basic_fstream<char>::open(std::string&)’
- datafile.open(filename1);
- ^
- project2.cpp:32:25: note: candidate is:
- In file included from project2.cpp:2:0:
- /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/include/c++/fstream:889:7: note: void std::basic_fstream<_CharT, _Traits>::open(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::_Ios_Openmode]
- open(const char* __s,
- ^
- /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/include/c++/fstream:889:7: note: no known conversion for argument 1 from ‘std::string {aka std::basic_string<char>}’ to ‘const char*’
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement