#include
#include
#define MAX 30
void push(char );
char stack[MAX];
int tos=0;
int main(){
char str[]=\"Arijit Saha\";
char *f
A variable which has automatic storage duration doesn't exist anymore in the calling function. Accessing to it leads to an undefined behavior (anything can happen). Here you are returning reverse
from rev
, which is a local variable.
Rather allocate the memory dynamically:
int *reverse = malloc(strlen(s)); /* + 1 for '\0' character ? */