Why do I get this error, (i added the header files and everything, this is where i m stuck)

+1 Ash Marz · June 23, 2015

  float fahrenheit;
    float celsius;
    float formulaf = (fahrenheit - 32) * 5/9;
    char str[20];
    float formulac = celsius * 9/5 + 32;
    printf("Choose either fahrenheit or celsius; ");
    scanf("%*s", &str);
    if (strcmp(str, "fahrenheit") ==0);
        printf("Enter the temperature in fahrenheit: ");
        scanf("%f", &fahrenheit);
        printf("%.2f fahrenheit is %.2f celsius", fahrenheit, formulaf);
        printf("Enter the temperature in celsius: ");
        scanf("%f", &celsius);
        printf("%.2f celsius is %.2f fahrenheit", celsius, formulac);

Post a Reply


Oldest  Newest  Rating
+1 Alan Johnson · June 23, 2015
Remove the semi-colon, it should be:
if (strcmp(str, "fahrenheit") ==0)
0 Ash Marz · June 23, 2015
here is the clear picture /images/forum/upload/2015-06-23/4fe54005fceebc006f13821c4b7aa017.png
0 Ash Marz · June 24, 2015
Thank You I did that, but I still get this error 
0 c student · June 24, 2015
scanf ("%s", str);
0 Ash Marz · June 24, 2015
if we should change it to scand("%s", str); 

then what is &str used for?
0 girish gogia · June 24, 2015
program will crash without '&'
0 c student · June 24, 2015
The address of operator returns the address of the specified variable.  Since arrays in C are passed with the address of the first element by default, it is not required for you to place the address of operator in front of it.  The only time you will need to use the address of operator on a buffer is when you want to specify an address of an element that's not the first.
  • 1



One of the most popular languages of all time.

Bucky Roberts Administrator