Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdbool.h>
  4. #include <string.h>
  5.  
  6. int main()
  7. {
  8. char str[256];
  9. printf("Input the string\n");
  10. fgets(str, 256, stdin);
  11. size_t ln = strlen(str) - 1;
  12. if (str[ln] == '\n')
  13. str[ln] = '\0';
  14. char *pch = strtok(str, " ,.;?!");
  15. int max_length = 0;
  16. char *max_str;
  17. while (pch != NULL)
  18. {
  19. if (strlen(pch) > max_length)
  20. max_str = pch;
  21. pch = strtok(NULL, " ,.;?!");
  22. }
  23. printf("The widest word: %s\n", max_str);
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement