Errors using pointers with Function in C

First of all I apologize, this is probably a simple question but I'm not very well versed in any coding. For this code, I need to use pointer syntax and define my own function to reverse a string. I'm not allowed to use strlen() in this situation. I've tried playing around with the pointers, but I always get the following errors:

incompatible type when assigning to type char[15] from type char

(I have to write this in pico, so I'm not exactly sure what line number it refers to. It appears to be somewhere around the point I call the strcmp() function

assignment makes integer from pointer without cast 

(This one appears to be when I define the s pointer in the function or around there)

Any and all help/troubleshooting ideas would be much appreciated. I'm using a gcc compiler, if that matters

#include<stdio.h>
#include<string.h>

char revcheck(char String[15]);

int main(void)
{
    char String[15];

    printf("Enter a string: \n");
    scanf(" %s", String);

    if (strcmp(String, "ENGR-awesome"))
    {
        printf("That's Right!");
    }
    else
    {
        String = revcheck(String);
    }

    return 0;
}

char revcheck(char String[15])
{
    char Letter, *end, *s;
    end = strchr(String, '\0');
    s = String;
    while (end > s)
        Letter = &end;
    *end = *s;
    *s = Letter;
    end--;
    s++;

    return 0;
}

Answers


Your revcheck() returns a char. You are trying to assign that to a char[].

You should have your revcheck() return a char*:

char* revcheck(char String[15]);

First you should bear in mind that C-string is an array of chars, and can be represented as char*, a pointer to this array. So, revcheck should not return char. This is the string where the compiler gives the error:

String = revcheck(String);

revcheck can reverse the string in the String array itself (in place) without returning anything. (You can count the len yourself and then swap elements.)


Need Your Help

Ng-if not hiding element when watched variable turns false

javascript jquery angularjs

I am trying to hide an element based on the width of the screen and a test variable. I am running into an edge case where the ng-if directive is not properly hiding an element despite the value being

Alternative of box-shadow

css css3

I want to give the box-shadow in my email but this property is not supported by gmail and yahoo then is there in any alternative trick to give box-shadow in the mail?