#include<stdio.h>
#include<string.h>
#include<malloc.h>
char *str_rev(char s[]){
static char *st = NULL;
static char *l;
int i = 0,c = 0;
st = malloc((strlen(s) * sizeof(*s))+1);
l = st;
if(s == NULL){
return "INVALID PARAMS"; // Added ;
}
for(i=0;s[i]!='\0';i++){
;
}
for(c=i-1;c >=0;c--){ // c = i -1
*l++ = s[c];
}
*l = '\0';
printf("\n s:%s \n l:%s \n",s,l);
//free(st); not needed commented.
// return l;
return st; // return st instead of l
}
int main(){
char a[]="Angus Declan R"; // Added ;
printf("\n %s \n",str_rev(a));
return 0;
}