OK, since i am not getting the answer am looking for, i am showing you a small source code of my program, i really hope that u understand it & sorry fot the newbie codez.

[
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
int numa = atoi(argv[1]);
int numb = atoi(argv[3]);
int sym = atoi(argv[2]);
int sum;
if (sym == 1)
{
sum = numa + numb;
printf("\n%d Plus %d= %d", numa, numb, sum);
}
else
printf("Error");
return 0;
}

/* INPUT: 1 1 1
OUTPUT: 1 Plus 1= 2 = GOOD :)

BUT

INPUT: 1.1 1 1.1
OUTPUT: 1 Plus 1= 2 =??????? HELP ME */
]

[]

Integers are not floating point. Using sscanf to convert the command line text is my recommendation; with error checking, and using the + symbol itself, it might be as follows.

#include <stdio.h>
 #include <stdlib.h>
 
 int main(int argc, char **argv)
 {
    double a, b;
    if ( argc > 3 )
    {
 	  if ( sscanf(argv[1], "%lf", &a) == 1 &&
 		   sscanf(argv[3], "%lf", &b) == 1 )
 	  {
 		 switch ( argv[2][0] )
 		 {
 		 case '+':
 			printf("%g + %g = %g\n", a, b, a + b);
 			break;
 		 default:
 			puts("Error");
 			break;
 		 }
 	  }
    }
    return 0;
 }
 
 /* my input/output
 C:\Test>test 5.1 + 6.3
 5.1 + 6.3 = 11.4
 */
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.