Code works but cant get link to show up

I was wondering if my coding is right so far? I have to make a program that detects different characters and how many from a link, but when i run it, it says the link couldnt be found.



#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <cctype>

char ch;
int charCnt= 0;
int alpha=0;
int upper=0;
int lower=0;
int digit=0;
int punct=0;
int space=0;

using namespace std;
int main()
{
ifstream in;
in.open("input.txt");
if(in.fail())
ch= in.get();

{
cout<< "Input file could not be open";
exit(-1);
}

while (in)
{
cout << ch;
charCnt++;
ch=in.get();

if (isalpha(ch))
{
alpha++;
}
else if (isupper(ch))
{
upper++;
}
else if(islower(ch))
{
lower++;
}
else if(isdigit(ch))
{
digit++;
}
else if(ispunct(ch))
{
punct++;
}
else if(isspace(ch))
{
space++;
}

}

cout<<endl<< "Character count" << charCnt<< endl;
cout<<endl<< "Alphabet count" << alpha<< endl;
cout<<endl<< "Uppercase count" << upper<< endl;
cout<<endl<< "Lowercase count" << lower<< endl;
cout<<endl<< "Digit count" << digit<< endl;
cout<<endl<< "Punctuation count" << punct<< endl;
cout<<endl<< "Whitespaces count" << space<< endl;

in.close();


return 0;
}
Please edit your post and make sure your code is [code]between code tags[/code] so that it has line numbers and syntax highlighting, as well as proper indentation.

Your error handling code is unconditional.
Topic archived. No new replies allowed.