-2

I just started programming and this is one of my first tasks. I really don't understand why this code is not working. any help would be greatly appreciated

#include <stdio.h>
#include <stdlib.h>

int main(int argc, const char * argv[])
{

    float temp;
    int result1;
    char  scale;
    char convert;
    char ch1 = 'F';
    char ch2 = 'f';
    char ch3 = 'C';
    char ch4 = 'c';
    char ch5 = 'K';
    char ch6 = 'k';

    float result;

    printf(" Please Enter Temperature: ");
    scanf("%f", &temp);
    printf("Scale is: ");
    scanf("%s", &scale);


    if(scale == 'F' || scale == 'f')
    {
        printf("convert to: ");
        scanf("%s", &convert);


        if(convert == 'c' || convert == 'C')
        {
            result = (temp-32)*(5/9);
            printf("original temperature: %f\n", temp);
            printf("scale conversion: %s to %s\n", scale, convert); 

in here the error appears, it says "format specifies type 'char*' but the argument has type 'char'??

            printf("result: %f\n", result);
        }

else
    if(scale == 'C' || scale == 'c')
    {
        printf("convert to:");
        scanf("%s", &convert);


        if(convert == 'f' || convert == 'F')
        {
            result= ((temp*1.8)+32);
            printf("original temperature: %f\n", temp);
            printf("scale conversion: %s to %s\n", scale, convert);
            printf("result: %f\n", result);

        }
else
    if(scale == 'K' || scale == 'k')
    {
        printf("convert to:");
        scanf("%s", &convert);

        if(convert == 'C' || convert == 'c')
        {
            result=(temp+273);
            printf("original temperature: %f\n", temp);
            printf("scale conversion: %s to %s\n", scale, convert);
            printf("result: %f\n", result);
        }
else
    if (scale == 'C' || scale == 'c')
    {
        printf("convert to:");
        scanf("%s", &convert);

        if(convert == 'K' || convert == 'k')
        {
            result=(temp-273);
            printf("original temperature: %f\n", temp);
            printf("scale conversion %s to %s\n", scale, convert);
            printf("result: %f\n", result);
        }
else
    if (scale == 'F' || scale == 'f')
    {
        printf("convert to:");
        scanf("%s", &convert);

        if (convert == 'K' || convert == 'k')
        {
            result=((temp+459)*0.55);
            printf("original temperature: %f\n", temp);
            printf("scale conversion %s to %s\n", scale, convert);
            printf("result: %f\n", result);
        }
else
    if (scale == 'K' || convert == 'k')
    {
        printf("convert to:");
        scanf("%s", &convert);

        if (convert == 'F' || convert == 'f')
        {
            result=(0.55*(temp-273)+32);
            printf("original temperature: %f\n", temp);
            printf("scale conversion %s to %s\n", scale, convert);
            printf("result: %f\n", result);
        }
    }
    }
    }
    }

    }
    }

    printf("\nthank you so much for using this program...press any key to exit\n");
    getchar();

    return 0;
}
Tommy
  • 99,986
  • 12
  • 185
  • 204

1 Answers1

3

The %s format specifier is for null-terminated strings only (which have type char*), not single characters (char). For single characters, use %c.

C. K. Young
  • 219,335
  • 46
  • 382
  • 435
  • 1
    When you post questions in the future, you will generally get good answers more quickly if you can format your code better. Your indentation is inconsistent, and that string of 6 closing braces all at the same indentation level at the end is especially silly. Also, your "error message here" note would be better if you included the actual compiler error and indicated *exactly* where in your code it refers to. You don't even have a %s next to your note. Lastly, please try to reduce your code to a [MCVE](http://stackoverflow.com/help/mcve). – skrrgwasme Aug 06 '14 at 23:02