What is a valid definition for the get_length function, which returns the length of a null-terminated string?

Advertisement

  • A
    int get_length(char *str) {
    int count=0;
    while(str[count++]);
    return count-1;
    }
  • B
    int get_length(char *str) {
    int count=0;
    while(str!=NULL){
    count++;
    str++;
    }
    return count;
    }
  • C
    int get_length(char *str) {
    int count=0;
    while((*str)++)
    count++;
    return count;
    }
  • D
    int get_length(char *str) {
    int count=0;
    while(str++)
    count++;
    return count;
    }
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Leave a Comment


Share via
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Send this to a friend