I am simply trying to read each character from a file and print them in the screen. For testing, I tried to print ascii value in a console screen first before printing characters.
the content of the file I am trying to read is below:
assign1_2.cpp:33:20: error: cannot convert 'std::string
{aka std::basic_string}' to 'const char*' for argument '1'
to 'int atoi(const char*)'
I used the code below
#include
#include
#include
#include
#include
using namespace std;
void CountLetters(string filename);
int main()
{
CountLetters("count.txt");
}
void CountLetters(string filename)
{
cout << filename << endl;
ifstream in;
in.open(filename.c_str(), ios::in);
vector<char> letter;
char temp;
while (!in.eof())
{
cout << in.get() << endl;
}
in.close();
}
After running these code and I see "-1" at the end in the console screen. Anyone please explain? thanks
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)