35 lines
681 B
C
35 lines
681 B
C
#include<stdio.h>
|
|
#include<stdlib.h>
|
|
#include<string.h>
|
|
|
|
int main(int argc, char * argv[]) {
|
|
long x, y;
|
|
char* position_x;
|
|
char* position_y;
|
|
|
|
x = strtol(argv[1], &position_x, 10);
|
|
y = strtol(argv[2], &position_y, 10);
|
|
|
|
if ((x == 0) && (position_x==argv[1])) {
|
|
puts("Entier invalide.");
|
|
return EXIT_FAILURE;
|
|
} else if (*position_x != '\0') {
|
|
puts("Conversion partielle !");
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
if ((y == 0) && (position_y==argv[2])) {
|
|
puts("Entier invalide.");
|
|
return EXIT_FAILURE;
|
|
} else if (*position_y != '\0') {
|
|
puts("Conversion partielle !");
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
long z = x * y;
|
|
printf("%d * %d = %d\n", x, y, z);
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|