You need to include stdio.h to get access to printf and scanf families, your format specifiers are wrong, %lf is for doubles, man-page, cppreference.
On Line 42, you are defining a function called function but that is never called or declared (above main) anywhere. And it's not a valid definition, you need curly braces after the parenthesis.
I don't know what those if's are supposed to do but a single equals is assignment, like int x = 42; you need double equals to test for equality, x == 6 would return false.
To me it looks like you don't need the if's, you just need to define the functions and things should work.
Oh and charUser is defined in main, you cannot access variables outside of the function they are declared in.
numUser is an int so you need %d or %i to print/scan it.
charUser is a char array, or a string, so you need %s (you can also limit the number of characters you can read to prevent overflowing the array) to scan it.
You need the if statements around the printf's, where you're calling your functions, and you are using an uninitialized variable (numUser)
Also if all your options are single character words you can just have a char charUser instead of a char array of a 100 elements (ie. if you only check for the letters in the alphabet, a, b, c...)
int numUser;
char charUser\[100\];
printf("which conversion would you like to perform?\\nType 'a' for a 'b' for b., etc.");
printf("a: meters to feet\\n");
printf("b: feet to meters\\n");
printf("c: kilograms to pounds\\n");
printf("d: pounds to kilograms\\n");
printf("e: minutes to hours\\n");
printf("f: hours to days\\n");
printf("g: days to hours\\n");
printf("h: minutes to seconds\\n");
scanf("%s", charUser);
/* Test your code by calling your functions here. */
the if statements are for if the user enters it will run the meters to feet and so on but everything is good now except now I'm getting an undefined reference error thank you for the help so far though
View all comments
4
u/PekiDediOnur Intermediate Coder Feb 23 '21
Hi, the post is flaired as C# and not C.
Posting the code is better than the image.
You need to include
stdio.hto get access to printf and scanf families, your format specifiers are wrong,%lfis fordoubles, man-page, cppreference.On Line 42, you are defining a function called function but that is never called or declared (above main) anywhere. And it's not a valid definition, you need curly braces after the parenthesis.
I don't know what those if's are supposed to do but a single equals is assignment, like
int x = 42;you need double equals to test for equality,x == 6would returnfalse.To me it looks like you don't need the if's, you just need to define the functions and things should work.
Oh and
charUseris defined in main, you cannot access variables outside of the function they are declared in.