When I manually test my program it compiles and works fine but when I try to use the autograder in the terminal I get this error. I am new to C and do not understand what it means and how to fix it.
My code:
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<stdlib.h>
int main(int argc, char* argv[]){
char *s = (char *)malloc(sizeof(char) * 100);
char prev = argv[1][0];
if(isdigit(prev)!=0){
printf("%s","ERROR");
return 0;
}
int count = 1;
for(int i=1; i<strlen(argv[1]); i++){
if(isdigit(argv[1][i])!=0){
printf("%s","ERROR");
return 0;
}
if(prev==argv[1][i]){
count++;
}else{
sprintf(s, "%s%c%d", s, prev, count);
count = 1;
}
prev=argv[1][i];
}
sprintf(s, "%s%c%d", s, prev, count);
if(strlen(s) > strlen(argv[1])){
printf("%s\n", argv[1]);
}else{
printf("%s\n", s);
}
free(s);
}