AL-zami AL-zami - 4 days ago 4x
C Question

Permutation of string

I am trying to implement a code where i have to permute a string.Whenever i try to execute my code i get the following errors and warnings;

1.passing argument 1 of permute makes integer from pointer without a cast

2.expected char but argument is of type char *

3.conflicting type for permute

what might cause those errors in my program?


void swap(char *first,char *second);
void permute(char a,int l,int r);

int main(){
char str[] = "ABC";
int size = strlen(str);
return 0;
void permute(char *a,int l,int r){
if (l==r){
int i;

void swap(char *first,char *second){
char *temp;
*temp = *first;
*first = *second;
*second = *temp;


There's an error in your function prototype. It's declared like this:

void permute(char a,int l,int r);

But defined like this:

void permute(char *a,int l,int r) {

Note that the type of the first argument does not match. You need to change the prototype to match the definition.

Unrelated to that, your swap function is using a pointer temp that is being dereferenced without being set. This is undefined behavior and will likely cause a core dump.

Since you're swapping characters here, you only need a char, not a char *.

void swap(char *first,char *second){
    char temp;
    temp = *first;
    *first = *second;
    *second = temp;