I keep getting these strange negative values when I run the code. Does anyone know what they are and how to get just an int (For example 10, 20, 8...)? Why do I always get a different and wrong value? When I run the code with arguments 2 and 3 it should output 10...
int main(int argc, char *argv[]) {
  int h;
  int a;
  int b;
  a = (int) argv[1];
  b = (int) argv[2];
  if (argc == 3) {
    h = 2 * (a + b);
    printf("The perimeter of the rectangle is %d\n", h);
  } else {
    fprintf(stderr, "Usage: %s <arguments>\n", argv[0]);
  }
}
Output:
The perimeter of the rectangle is -1874251136
or
The perimeter of the rectangle is -1424723328
or
The perimeter of the rectangle is -940059169
 
     
     
    