0

Why input values behaves different when I enclosed %d in ()

Scanf("(%d)",&x); entered value:1, output:0 Why?? https://code.sololearn.com/cO7GAAUmPQ91/?ref=app

24th Jan 2022, 4:53 PM
Saumya Mishra
Saumya Mishra - avatar
3 Answers
+ 1
Because that way, you are expected to also enter the value within parentheses. Try to provide (12345) as input and you'll see what I mean. If you're not gonna use <x> in arithmetic operation in any ways, you probably wanna read a C-string instead, cause parentheses will be read without any problem for a C-string .
24th Jan 2022, 5:26 PM
Ipang
0
To learn how to use the functions type "man function" like in your case "man scanf" in your browser.
24th Jan 2022, 6:15 PM
William Owens
William Owens - avatar
0
Because function scanf() dont have Format Specifier like yours (%d) , and variable x didn't get value from input. But x have 0 value by default, and you see output from yours printf - Zero. Some of the % specifiers that you can use , you can see here https://www.freecodecamp.org/news/format-specifiers-in-c/
24th Jan 2022, 9:33 PM
Smith Welder
Smith Welder - avatar