You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
programming-examples/c/Basic/C Program to Print the Word...

38 lines
926 B
C

/*
* C Program to Print the Words Ending with Letter S
*/
#include <stdio.h>
#include <string.h>
char str[100];
void main()
{
int i, t, j, len;
printf("Enter a string : ");
scanf("%[^
]s", str);
len = strlen(str);
str[len] = ' ';
for (t = 0, i = 0; i < strlen(str); i++)
{
if ((str[i] == ' ') && (str[i - 1] == 's'))
{
for (j = t; j < i; j++)
printf("%c", str[j]);
t = i + 1;
printf("
");
}
else
{
if (str[i] == ' ')
{
t = i + 1;
}
}
}
}
Enter a string :
Welcome to Illumin8's C Programming Class, Welcome Again to C Class ! Illumin8's Class