I have another problem...
Let's start with said code:
#include <iostream>
#include <fstream> //I have tried using fstream.h like my teacher instructs me to do/
#include <cstdlib> //but it gives me another error: see below, in actual post.
using std::cout;
using std::cin;
using std::ios;
using std::endl;
//using namespace std;
using std::ifstream;
int main()
{
char filename[16];
int letters = 0;
char letter_counter[2];
int end_of_lines = 0;
ifstream infile;
cout << "Please enter the file you want to search and include its extension\n i.e. filename.txt\n>";
cin.get(filename,16);
cin.ignore(80,'\n');
infile.open(filename, ios::in);
if(!infile)
{
cout << "There were " << letters << " letters, and " << end_of_lines << " end of line characters in " << filename << '.' << endl;
return 0;
}//if
else
{
do
{
infile >> letter_counter;
//if(letter_counter == 32)
if(letter_counter == '\n') //|39|error: ISO C++ forbids comparison between pointer and integer|
{
end_of_lines++;
}//if
//if(letter_counter <= 122 && letter_counter >= 65)
if(letter_counter <= 'z' && letter_counter >= 'A') //|45|error: ISO C++ forbids comparison between pointer and integer|
{
letters++;
}//if
}while(!infile.eof());//while
}//else
cout << "There were " << letters << " letters, and " << end_of_lines << " end of line characters in " << filename << '.' << endl;
infile.close();
return 0;
}//main
When I compile this code, I'm getting the too commonly seen:
In function 'int main()':|
|39|error: ISO C++ forbids comparison between pointer and integer|
|45|error: ISO C++ forbids comparison between pointer and integer|
|45|error: ISO C++ forbids comparison between pointer and integer|
||=== Build finished: 3 errors, 0 warnings ===|
as you can see, I've tried to compare what's in both variables to see whether the current letter coming in from the file is an end-of-line character or a letter.
when trying to use <fstream.h>(like my teacher instructs us to use >_< ) and removing the using std::ifstream, i get the below errors:
|2|error: fstream.h: No such file or directory|
||In function 'int main()':|
|19|error: 'ifstream' was not declared in this scope|
|19|error: expected ';' before 'infile'|
|25|error: 'infile' was not declared in this scope|
|39|error: ISO C++ forbids comparison between pointer and integer|
|45|error: ISO C++ forbids comparison between pointer and integer|
|45|error: ISO C++ forbids comparison between pointer and integer|
||=== Build finished: 7 errors, 0 warnings ===|
I still get the ISO C++ error, but this time it's saying that I don't have <fstream.h>...
I've downloaded <fstream.h> and <_def.h> and reinstalled Code::Blocks twice now...
what don't usderstand is why I'm suddenly getting this error, when i've been able to use file I/O before...
If someeone could help, that would be great.
Derek