The problem says that if we are given a text we have to post every sentence on a new row. And we know that the sentences are sepparated only with "." and "!".
For example:
"It's Easter. I've sent him a card."
output:
"It's Easter."
"I've sent him a card."
Here's my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
#include <string>
usingnamespace std;
int main ()
{
char s[100], *a=".", *b="!";
int n, i;
cout << "s= "; cin.get(s, 100);
n=strlen(s);
for (i=1; i<n; i++)
{
if ((strcmp(a,s[i])==0)||(strcmp(b,s[i])==0))
cout << endl;
else
cout << s[i];
}
}
The problem is at 12th row. The compiler says "invalid conversion from `char' to `const char*'". And i don't know how to change that. Any help? It would be better if you could modify that row. Any tip will be appreciated! Thank you!
is that you are trying to compare the character array pointed by 'b' with a single character s[i].
And in general you incorrectly realize your task. Instaed of pointers 'a' and 'b' and function strcmp I think you should use function strtok of define two single characters '.' and '!' and use it in a searching operation.