Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- char** fkt(char *str, int *a)
- {
- int wrs=1, x=0, y;
- for(int i=0; str[i]!='\0';i++)
- {
- if(str[i]==' ')wrs++;
- }
- char **tab2=malloc(wrs*sizeof(char*));
- wrs=0;
- for(int i=0; str[i]!='\0';i++)
- {
- if(str[i]==' ')
- {
- y=i;
- char*tab1=malloc(y-x+1);
- for(int j=x; j<y;j++)tab1[j-x]=str[j];
- tab1[y-x]='\0';
- tab2[wrs++]=tab1;
- }
- }
- a=wrs-1;
- return tab2;
- }
- int main(void)
- {
- char tab[]="ala ma kota";
- int wsk;
- char **wyn=fkt(tab,&wsk);
- for (int i=0; i<wsk;i++)
- {
- printf("%s ",tab[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement