I have to write a program that reads a text file that contains +/- values and characters and outputs any invalid characters (anything that is not an +/- integer) and also at the end i have to have it print out the total number of how many invalid characters there are. this is my code so far and the problem im having is that it outputs everything

#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

int main()
{
ifstream data("data.txt");
char ch;


while(data.get(ch))
{
cout<<ch;
}
data.close();
cout<<endl;
system("PAUSE");
return 0;
}

Recommended Answers

All 2 Replies

Where do you tell it not to output everything?

i don't. that's why i need help. i need help in figuring out how to filter our anything that isn't a +/- integer

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.