Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main(int argc, char **argv) {
- if (argc == 1) {
- printf("Error: expected some-command line parameters\n");
- return 0;
- }
- int i;
- char *longestString = argv[1];
- for (i = 2; i < argc; i++) {
- if (strlen(argv[i]) > strlen(longestString)) {
- longestString = argv[i];
- }
- }
- printf("The longest string from the command line is: %s\n", longestString);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement