CHAR FUNCTION WITH RETURN

I have created a function which returns 0 when the string has do not have distinct characters returns 1 when it has …I THINK THAT ERROR IS IN DECLARATION OF FUNCTION. Please HELP

#include<bits/stdc++.h>
using namespace std;

char fun(char a[], int n)
{
int flag=1;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(a[i]==a[j]){
flag=0;
return (0);
break;
}
}
}
if(flag==1){
return (1);
}
}
int main()
{
char str[50];
cin>>str;
fun(str, strlen(str));
return 0;
}

What error? Compile error? Not giving the correct result? If so, for what testcase?

Help with what? XD

Also: Please format your code!!! :smiley:

1 Like

THE COMPILER GIVES NO OUTPUT

You mean it output no error messages? Great, then presumably it compiled successfully. You still haven’t actually told us what’s wrong nor why you need help :slight_smile:

1 Like

THANK YOU ,I FORGOT TO USE FUNCTION IN IF ELSE STATEMENT

if( fun(str, strlen(str))){
cout<<“yes”;
}
else
cout<<“no”;

1 Like