470,848 Members | 1,829 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,848 developers. It's quick & easy.

bool & scanf

Hi,

How to accept bool value from stdin, using scanf?

e.g.

bool b ;
scanf_s("%d", &b);

It will show:

Unhandled exception at 0x0040a083 in MSFT.exe: 0xC0000005: Access
violation writing location 0xffffffe4.
Thanks.
Jun 27 '08 #1
1 20952
On 2008-04-20 11:55, howa wrote:
Hi,

How to accept bool value from stdin, using scanf?

e.g.

bool b ;
scanf_s("%d", &b);

It will show:

Unhandled exception at 0x0040a083 in MSFT.exe: 0xC0000005: Access
violation writing location 0xffffffe4.
scanf can not read into boolean, you have to read into an int (or
similar) and then convert the value to bool (or you can read in a string
and convert the text to bool).

--
Erik Wikström
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Peter Mount | last post: by
4 posts views Thread by sushant | last post: by
13 posts views Thread by Betaver | last post: by
30 posts views Thread by James Daughtry | last post: by
reply views Thread by sala | last post: by
7 posts views Thread by Army1987 | last post: by
2 posts views Thread by sophia | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.