Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void unos (char *s) {
- char c;
- int i=0;
- do {
- c=getchar();
- s[i]=c;
- i++;
- }
- while (c!='\n' && i<100);
- s[i-1]='\0';
- }
- int length (char *s)
- {
- int duzina=0;
- while (*(s++)!='\0') duzina++;
- return duzina;
- }
- void cut(char *string, int indeks, int len)
- {
- int i;
- for(i = indeks; i <= length(string) - len; i++)
- {
- string[i] = string[i + len];
- }
- }
- int JeLiSlovo (char c) {
- if (tolower(c)>='a' && tolower(c)<='z') return 1;
- return 0;
- }
- void IzbaciRijecNDuzine (char *s, int n) {
- int poc, kraj, i, duz=length(s);
- for (i=0; i<duz; i++) {
- if (JeLiSlovo(s[i]))
- {
- poc=i;
- i++;
- while (JeLiSlovo(s[i])) i++;
- kraj=i;
- if (kraj-poc>n) {
- cut(s,poc,kraj-poc);
- i-=(kraj-poc);
- }
- }
- }
- }
- int main () {
- char s[100]="Trebam da izbacim rijec selma";
- IzbaciRijecNDuzine(s,5);
- printf("%s", s);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement