Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Napisati funkciju char* shortest_word(char** s)
- koja vraća prvu najkraću reč (string) u nizu reči s.*/
- #include <string.h>
- char* shortest_word(char** s) {
- char *shor_w = NULL;
- while(s && *s) {
- if(!shor_w || strlen(*s) < strlen(shor_w))
- shor_w = *s;
- s++;
- }
- if(shor_w) {
- char *t=calloc(sizeof(*t),strlen(shor_w)+1);
- strcpy(t, shor_w);
- shor_w = t;
- }
- return shor_w;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement