Easy C question from a beginner

Danimal1209

Senior member
Nov 9, 2011
355
0
0
Trying to understand why I get a "argument doesn't match prototype" error

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

void convert_temp(int degreeIn, char scaleIn);

int main() 
{
    int degree1, degree2;
    char scale1, scale2;
    printf("Enter a temperature and a scale\n");
    scanf("%d %c", &degree1, &scale1);
    convert_temp(degree1, scale1);
    printf("%d %c = %d %c\n", degree1, scale1, degree2, scale2);
    return (0);
}

void convert_temp(degreeIn, scaleIn)
{
    printf("HI");
}
And whats the HTML for putting this in a code clock?

Code block created. Check here for more info on how to use them.

Markbnj
Programming moderator
 
Last edited by a moderator:

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
You should give the line on which the compiler is complaining. It's been a long time but I'm going to guess that you have the forward declaration and the definition of your function wrong. I'm thinking that instead of:

void convert_temp(int degreeIn, char scaleIn);
void convert_temp(degreeIn, scaleIn)
{
printf("HI");
}

What you want is:

void convert_temp(int degreeIn, char scaleIn);
void convert_temp(int degreeIn, char scaleIn)
{
printf("HI");
}

Or alternatively:


void convert_temp(int, char);
void convert_temp(int degreeIn, char scaleIn)
{
printf("HI");
}
 

veri745

Golden Member
Oct 11, 2007
1,163
4
81
Yes, the type of each argument is required in both the prototype and function definition.

The variable names are purely option in the prototype.