Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int extrageCuvant(char dest[], char sir[], char separatori[], int pozitie)
- {
- int i=0;
- int contorCuvant=0;
- int k=0;
- struct myStr { // struct's as good as class
- static int cautaLitera(char s[], char c)
- {
- for(int poz=0; s[poz]; poz++)
- if (s[poz]==c) return 1;
- return 0;
- }
- };
- int lung=0;
- while (sir[lung++]);
- while(sir[k] && contorCuvant<pozitie)
- {
- if (myStr::cautaLitera(separatori, sir[k])) while (myStr::cautaLitera(separatori, sir[k])) k++;
- while (!myStr::cautaLitera(separatori, sir[k]))k++;
- contorCuvant++;
- }
- if (k>lung) return 0;
- if (myStr::cautaLitera(separatori, sir[k])) while (myStr::cautaLitera(separatori, sir[k])) k++;
- if (k>lung) return 0;
- while (sir[k])
- {
- dest[i]=sir[k];
- i++;
- k++;
- if (myStr::cautaLitera(separatori, sir[k]) || k==lung) break;
- }
- dest[i]=0;
- if (dest[0]) return 1;
- return 0;
- }
Add Comment
Please, Sign In to add comment