I'm making this chatbox project called The Not A Friend Project... Anyway, this project is based on a former chat box, hal. I don't remember the creater, he was on this board a while back and posted his creation. Although, he didn't give source code, so I'm starting from scratch. Here's the source code:
Code:
#include <iostream.h>
#include <stdio.h>
#include <fstream.h>
#include <string.h>
#include <conio.h>
char blank[]=" ";
class mainbot
{
public:
mainbot::mainbot();
~mainbot();
int userintf();
int checkinput();
int checkoutput();
private:
char inp[75];
int inpno;
char responce[75];
char inchk[75];
int inchkcnt;
char str;
};
mainbot::mainbot()
{
}
mainbot::~mainbot()
{
}
int mainbot::userintf()
{
cin.getline(inp,75);
checkinput();
checkoutput();
cout << responce;
return 0;
}
int mainbot::checkinput()
{
ifstream input("input.txt");
input >> str;
inchkcnt=1;
while(strcmp(inchk,blank)||!strcmp(inchk,inp))
{
strtok(str, inchkcnt);
inchk=strtok(NULL, inchkcnt);
inchkcnt++;
}
if(!strcmp(inchk,blank))
{
cout << "I don't understand." << endl;
}
else
{
input.close();
checkoutput();
}
}
int mainbot::checkoutput()
{
ifstream output("output.txt");
output >> str;
strtok(str, inchknt);
responce=strtok(NULL, inchknt);
output.close();
}
int main()
{
mainbot interf;
interf.userintf();
return 0;
}
I've gone through debugging for a while bringing 14 errors down to three:
Code:
E:\Programs\Projects\Tests\Chat Bot\notafriend\nofsource.cpp(45) : error C2664: 'strtok' : cannot convert parameter 1 from 'char' to 'char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
E:\Programs\Projects\Tests\Chat Bot\notafriend\nofsource.cpp(46) : error C2664: 'strtok' : cannot convert parameter 2 from 'int' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
E:\Programs\Projects\Tests\Chat Bot\notafriend\nofsource.cpp(63) : error C2065: 'inchknt' : undeclared identifier
They seemed to have either a problem with strtok or with the variables they are taking in. Does anybody know how to solve this? If you see any other problems I may not have picked up, could you post the cures? Thanks.