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;
- while (c=getchar(), c!='\n')
- *(s++)=c;
- *s='\0';
- }
- int length(char *string)
- {
- int len = 0;
- while(*(string++) != '\0') len++;
- return len;
- }
- int br_rijeci(char *string)
- {
- int i, br=0;
- for(i = 0; i < length(string); i++)
- {
- if(string[i] != ' ')
- {
- while(i < length(string) && string[i] != ' ')
- {
- i++;
- }
- br++;
- }
- }
- return br;
- }
- void cut(char *string, int indeks, int len)
- {
- int i;
- for(i = indeks; i <= length(string) - len; i++)
- {
- string[i] = string[i + len];
- }
- }
- void IzbaciNtu (char *s, int n) {
- if (n<1 && n>br_rijeci(s)) return 0;
- int duz=length(s);
- int i, br=0, poc=0, kraj=0;
- for(i = 0; i <duz; i++)
- {
- if(s[i] != ' ')
- { poc=i;
- while(i < duz && s[i] != ' ')
- {
- i++;
- }
- kraj=i;
- br++;
- }
- if (br==n) {
- cut(s,poc, kraj-poc+1);
- }
- }}
- int main () {
- char c[100];
- unos(c);
- printf("%s\n",c);
- IzbaciNtu(c,2);
- printf("Nova rijec: %s",c);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement