Hello, is me again, im trying to improve my program with another function
it should print as many senteces on one line in the output, as user will enter as the parameter in the command line
sentenece is characterized with sign '.'
if you have sentences wchich ends with '...' then consider the last dot as an end of the sentence
but if you have '. . . ' (three dots with spaces after each one) then consider this as three different sentences
so i have this code, - i tried altered code that you suggested me in the previous topic
at first, ive just tried to do the basic thing, that it should count dots in the input
and if the number of dots equal the parameter then it should put new line
void ParameterSPL(int argc, char *argv[]) //spl means sentences per line
{
unsigned long int counter = 0;
unsigned long int pom;
int c;
int start= TRUE;
int spaceNeeded=TRUE;
pom = SpracujParameter(argc, argv);
// in variable pom there is a number of sentences wich should be print on one
// line in the output, in function SpracujParameter i used function
// strtoul, to convert parameter into the variable with data type unsigned lont int
while ( (c = getchar() ) != EOF )
{
if (isspace(c))
{
spaceNeeded = FALSE;
while ( (c = getchar() ) != EOF && isspace(c))
{}
}
if (c == '.') // if there is an dot in the input
{
counter++; // then increase the variable counter
}
if (c != EOF)
{
if (start == FALSE && spaceNeeded == FALSE)
{
putchar(' ');
}
spaceNeeded = TRUE;
putchar(c);
if (counter == pom) //
{
putchar('\n'); // put new line
counter = 0; // reset the counter
}
if(c == '\n')
start = TRUE;
else
start = FALSE;
}
}
}
so and the problem is here, i will demonstrate it on the input and outputs i have been testing
i entered number 3 as parameter
input
Tak teda vsetci vieme. Ze sa nemam dobre. Vsetko su sracky. Veronika na mna kasle.
Nechapem preco to robi. vy hej ?. ja teda nie. ved ma lubi. aspon tak vravi. hm. cele je to divne. chcem ju pri sebe.
a nie v pici daleko. preco za mnou nemoze dojst. preco za mnou nemoze dojst ked vravi ze ma lubi.
output
Tak teda vsetci vieme. Ze sa nemam dobre. Vsetko su sracky.
Veronika na mna kasle. Nechapem preco to robi. vy hej ?.
ja teda nie. ved ma lubi. aspon tak vravi.
hm. cele je to divne. chcem ju pri sebe.
a nie v pici daleko. preco za mnou nemoze dojst. preco za mnou nemoze dojst ked vravi ze ma lubi.
so as you can see, there is a white space in front of each new sentence, and there should not.... and how to code, that '...' will be recognized as one sentence ended with three dots, and '. . . ' will be recognized as three different sentences, i guess i can make this somehow with using macros, could i ? so could someone help me with this one ?