- #1
kbaumen
- 192
- 0
Hi.
I'm kinda learning C at home by myself and was just to compile another small program when I encountered problem with compiling.
Here's the code:
and here are the lines from compiler:
I'm getting frustrated why isn't this working. I don't understand why is there a problem.
I don't really have any work to show you except the code, I'm just curious why isn't it working. Help would be appreciated.
I'm kinda learning C at home by myself and was just to compile another small program when I encountered problem with compiling.
Here's the code:
Code:
#include <stdio.h>
#include <math.h>
int main(int argc, char **argv)
{
float p, S;
if (argc != 3)
{
fprintf(stderr, "Usage: %s <side_a> <side_b> <side_c> \n", argv[0]);
}
p = (argv[1] + argv[2] + argv[3]) / 2; //13th line
S = sqrt(p * (p - argv[1]) * (p - argv[2]) * (p - argv[3])); //14th line
printf("Area of this triangle is: %f \n", S);
return 0;
}
and here are the lines from compiler:
Code:
kbau@kbox:~/prj/c/test/exercises$ gcc uzd1.c -o uzd1 -Wall
uzd1.c: In function ‘main’:
uzd1.c:13: error: invalid operands to binary +
uzd1.c:14: error: invalid operands to binary -
uzd1.c:14: error: invalid operands to binary -
uzd1.c:14: error: invalid operands to binary -
I'm getting frustrated why isn't this working. I don't understand why is there a problem.
I don't really have any work to show you except the code, I'm just curious why isn't it working. Help would be appreciated.
Last edited: