Advertisement
dancidenis

lab9p6

Dec 14th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define LEN     10
  4. //6. Split string Write a function that takes as parameter a string,
  5. //an array of pointers and its length and fills the array with addresses to the beginning of each (whitespace-separated)
  6. //word in the string (similar to the argv[] array of main). Terminate the array with a NULL pointer after the last valid address.
  7. void function(char *s ,int *v[],int l)
  8. {  v[1]=s;
  9.     for(int i=1,j=2;s[i];++i){
  10.      //v[l]=NULL;
  11.     if(isspace(s[i])){
  12.        v[j]=s+i+1;
  13.        j++;
  14.     }}
  15.    v[l+1]=NULL;
  16.    for( int j=1;v[j]!=NULL;j++)
  17.    {
  18.  
  19.        printf("%s\n",v[j]);
  20.    }
  21.  
  22.  
  23.   }
  24. int main()
  25. { int *v[10];
  26.     function("Ana are mere si ananas",v,5);
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement