Hey everyone.
BKJ here, need some help with a homework, really appreciate some help.
Heres the question:
Write a program that reads one line of text, one character at a time, and then prints it with all its blanks, commas, astricts (*) and periods removed.
Heres my answer:
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
void main()
{
char a[80];
cout << "Input a line of text, and the program shall print the line with \nthe blanks, commas,";
cout << " asterixs and periods removed: " << endl;
int i = 0;
cin.get(a[i]);
while(a[i] != '\n'|| i != 80)
{
cin.get(a[i]);
i++;
}
i = 0;
cout << "You entered: " << endl;
while(a[i] != '\0')
{
if(a[i] != ' ' || a[i] != ',' || a[i] != '*' || a[i] != '.')
{
cout.put(a[i]);
}
else
{
cout.put(a[i]);
}
if(a[i] == '\0')
{
break;
}
}
cout << endl;
}
It never stops inputting characters, just keeps on going, then it suddenly closes
Using Microsoft Visual C++ Express Edition 2008