I am looking to check if two string are permutations of each other. I am using the following code :
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
void sort(char *str)
{
char temp;
for(int i=0;i<strlen(str);i++)
{
if(str[i]>str[i+1])
{
temp=str[i];
str[i]=str[i+1];
str[i+1]=temp;
}
}
}
int main()
{
char string1[10],string2[10];
int val;
cout<<"Enter first string";
gets(string1);
cout<<"Enter second string";
gets(string2);
val = strcmp(sort(string1),sort(string2));
if(val==0)
{
cout<<"Same strings"<<endl;
}
else
{
cout<<"Different Strings"<<endl;
}
return 0;
}
But I am getting a "invalid use of void expression error" at the strcmp line. How do I fix this ? Thanks