So I have a function that takes in a file input character by character and forms the characters into sentences to be modified. One of the modifications to be done is to make a run on sentence in this instance. It will take two sentences and form a run-on sentences by removing the punctuation between them and concatenating them.
Here is my code:
void runOn(char sentence, ifstream & fin, int counter)
{
char ch;
int sentCounter = 0;
bool sentenceEnd = false;
while(sentCounter<=2)
{
char tempSent[SENT_LENGTH];;
do
{
fin.get(ch);
for(int i = 0; i<SENT_LENGTH;i++)
{
tempSent[i] = ch;
}
if(ch == '.' || ch == '?' || ch == '!')
{
sentCounter++;
sentenceEnd = true;
}
}while(sentenceEnd == false);
strcat(sentence,tempSent);
}
}
The counter passed is only used because the function should only run for the first two sentences.
When I attempt to compile, I get this error:
function.cpp:36:29: error: invalid conversion from 'char' to 'char*' [-fpermissive]
strcat(sentence,tempSent);
Edit: I should add, I'm only allowed to use C style null terminated character arrays
The error is very clear, strcat
is declared as char * strcat ( char * destination, const char * source );
, however, sentence
is not char*
, you must convert sentence
from char
to char*
.
Since I don't know where sentence
comes from, I can't give further advice, may be you should post the function which called the runOn
.
Maybe you can simply change void runOn(char sentence, ifstream & fin, int counter)
to void runOn(char* sentence, ifstream & fin, int counter)
See declaration of strcat
here