Language: C

int main(void) {
  char s[26];
  
  scanf("%s", s);
  
  if (strlen(s) == 26) {
    for (int  i = 25; i >= 0; i--) {
      
      if (i == 0) {
        printf("-1");
        exit(0);
      }
      
      if (s[i] != 'z' ) {
        
        int flag = 0;
        for (int j = 0; j < i+1; j++) {
          if (alp[search(s[i]) + 1] == s[j]) {
            flag = 1;
          }
        }
        
        if (flag == 0) {
          s[i] = alp[search(s[i]) + 1];
          char ans[26];
          for (int k = 0; k < i+1; k++) {
            ans[k] = s[k];
          }
          printf("%s", ans);
          exit(0);
        }
        
        
      }
      
    }
  } else {
    char new = 'a';
    
    for (int j = 0; j < 26; j++) {
      
      int flag = 0;
      for (int i = 0; i < strlen(s); i++) {
        if (new == s[i]) {
          flag = 1;
        }
      }
      
      
      
      if (flag == 0) {
        s[(int)strlen(s)] = new;
        printf("%s", s);
        exit(0);
      } else {
        new = alp[j+1];
      }
      
    }
  }
  
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:4:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    4 |   scanf("%s", s);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int main(void) {
main.c:4:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    4 |   scanf("%s", s);
      |   ^~~~~
main.c:4:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:6:7: error: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
    6 |   if (strlen(s) == 26) {
      |       ^~~~~~
main.c:1:1: note: include '<string.h>' or provide a declaration of 'strlen'
  +++ |+#include <string.h>
    1 | int main(void) {
main.c:6:7: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch]
    6 |   if (strlen(s) == 26) {
      |       ^~~~~~
main.c:6:7: note: include '<string.h>' or provide a declaration of 'strlen'
main.c:10:9: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   10 |         printf("-1");
      |         ^~~~~~
main.c:10:9: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:10:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:10:9: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:11:9: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
   11 |         exit(0);
      |         ^~~~
main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit'
  +++ |+#include <stdlib.h>
    1 | int main(void) {
main.c:11:9: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
   11 |         exit(0);
      |         ^~~~
main.c:11:9: note: include '<stdlib.h>' or provide a declaration of 'exit'
main.c:18:15: error: 'alp' undeclared (first use in this function)
   18 |           if (alp[search(s[i]) + 1] == s[j]) {
      |               ^~~
main.c:18:15: note: each undeclared identifier is reported only once for each function it appears in
main.c:18:19: error: implicit declaration of function 'search' [-Wimplicit-function-declaration]
   18 |           if (alp[search(s[i]) + 1] == s[j]) {
      |                   ^~~~~~
main.c:29:11: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   29 |           printf("%s", ans);
      |           ^~~~~~
main.c:29:11: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:30:11: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
   30 |           exit(0);
      |           ^~~~
main.c:30:11: note: include '<stdlib.h>' or provide a declaration of 'exit'
main.c:53:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   53 |         printf("%s", s);
      |         ^~~~~~
main.c:53:9: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:54:9: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
   54 |         exit(0);
      |         ^~~~
main.c:54:9: note: include '<stdlib.h>' or provide a declaration of 'exit'