scanf

I'm running thisc code in 64bit linux.
However, my scanf is not stopping and keep taking new inputs.
ex)
% ./test1
Multiplicand & Multiplier(in hex):
2 4
3245
23 34
2
3 43
^C

please help!

1
2
3
4
5
6
7
8
9
10
11
12
  int main(void){
	int result1, result2, result3, hex1, hex2;
	// request user input
	printf("Multiplicand & Multiplier(in hex):\n");
	scanf(" %x %x",&hex1,&hex2);
	// store unsigned version
	int unsigned usign1=hex1;
	int unsigned usign2=hex2;
.
.
.
.
Do you realize that the "%x" format specifier expects unsigned int variables, not int? And note using variables that don't match the format specifier produces undefined results.


Topic archived. No new replies allowed.