Hello, I'm new in C. I'm getting warning:

warning: format '%s' expects type 'char *', but argument 2 has type 'char (*)[256]'

Here is the code:

typedef struct {
    char operation[256];
    char value[256];
    unsigned long long key;
} Input;

int main()
    Input input;
    while (scanf("%s",&input.operation) !=EOF) {
            if (input.operation[0]=='+') {
                scanf("%s %llu",&input.value,&input.key);
    return 0;

Please help, how to fix this warning.

Remove the & before input.operation and input.value because they are already passed as pointers. It is not necessary to use & before character arrays unless you want to pass a pointer to somewhere other than at the first character in the array.

If you want to use & then do it like this: &input.operation[0], but that is just redundent as explained above.

Many thanks :) I understand it now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.