Heh, well my daily project is near finished, and I was looking around for a way to get rid of punctuation from a character array. I looked through the web a bit, and only found immensely complicated formulas which I did not feel like dealing with.
So my question is: is there a simple way to get rid of punctuation using character arrays?
Also, in case you are interested, my project that I have been working on today is a 'bot' where you ask it questions, and it gradually builds up a data-base. Sort of like a small wikipedia. Here is the source code, if you feel like playing around with it:
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
char user[255];
do{
cout << "Talk: ";
cin.getline (user,255);
for(int x=0;x<strlen(user);x++)
{
if ( user[x] >= 'A' && user[x] <= 'Z' )
user[x] = static_cast<char> ( user[x] + 'a' - 'A' );
}
char question[255][255], answer[255][255], userans[255];
int ans=0, x=0;
ifstream fromfile("questions.txt");
for(x=1;x<50;x++)
{
fromfile.getline(question[x], 255);
if(strcmp (question[x], user) == 0)
ans = x;
}
fromfile.close();
ifstream tofile("answers.txt");
for(x=1;x<50;x++)
tofile.getline(answer[x], 255);
tofile.close();
if(ans==0)
{
cout << "I am sorry, but I do not know. What would your answer be?: ";
cin.getline(userans,255);
ofstream intofile("answers.txt",ios::app);
intofile << endl << userans;
intofile.close();
ofstream tofile("questions.txt",ios::app);
tofile << endl << user;
tofile.close();
}
else
cout << "Botman says: " << answer[ans] << endl;
}while(strcmp ("let me leave", user)!= 0);
}