Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define LEN 10
- //6. Split string Write a function that takes as parameter a string,
- //an array of pointers and its length and fills the array with addresses to the beginning of each (whitespace-separated)
- //word in the string (similar to the argv[] array of main). Terminate the array with a NULL pointer after the last valid address.
- void function(char *s ,int *v[],int l)
- { v[1]=s;
- for(int i=1,j=2;s[i];++i){
- //v[l]=NULL;
- if(isspace(s[i])){
- v[j]=s+i+1;
- j++;
- }}
- v[l+1]=NULL;
- for( int j=1;v[j]!=NULL;j++)
- {
- printf("%s\n",v[j]);
- }
- }
- int main()
- { int *v[10];
- function("Ana are mere si ananas",v,5);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement