Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(int argc, char **argv) {
  5. if (argc == 1) {
  6. printf("Error: expected some-command line parameters\n");
  7. return 0;
  8. }
  9.  
  10. int i;
  11. char *longestString = argv[1];
  12.  
  13. for (i = 2; i < argc; i++) {
  14. if (strlen(argv[i]) > strlen(longestString)) {
  15. longestString = argv[i];
  16. }
  17. }
  18.  
  19. printf("The longest string from the command line is: %s\n", longestString);
  20.  
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement