Passing Command Line Arguments

I need to pass values from the command line and add those values together and output the value, unfortunately it's just giving the answer 0.0000.

Inside my command arguments i have the numbers: 15 16

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  #pragma warning(disable : 4996)
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
	int pause;
	float Value1, Value2, Read1, Read2, Value3;
	int numberOfErrors = 0;
	//start by checking that 2 numbers was input - so the value of argc is 3
	if (argc != 3)
	{
		numberOfErrors++;
		printf("this programme should be called with two parameters\n");
	}
	if (argc == 3)
	{
		
		Read1 = sscanf(argv[1], "%d", &Value1);
		printf(" The number entered was %f \n", Value1);
		Read2 = sscanf(argv[2], "%d", &Value2);
		printf(" The number entered was %f \n", Value2);
		Value3 = Value1 + Value2;
		printf("The sum of the two numbers is %f \n", Value3);
	}
		
	
	scanf("%d", &pause);//so we can read any messages
	return (0);
}
My compiler wrote:
18:40: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘float*’
20:40: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘float*’
Thanks for checking for me, i have tried multiple variants so far with no success.

I have tried changing the float to an int just in case but it still is not reading the values and outputting 0.000.

Also i have tried atof instead of sscanf with the values stored as both int and floats with no success.

/stumped.

Is there something wrong possibly with my command argument?

http://postimg.org/image/qyx2ak6az/


Last edited on
Thank You :) I figured it out with your help.
Topic archived. No new replies allowed.