Char to Boolean.

Hey everyone,

This is probably very simple to some but I have been working on it for a while and im stuck. Im reading data from a text file and one column is all Y and N, Y being true, and N being false. I need to convert the Y and N values in the array to 1 and 0 in Boolean. Anyone know how I could go about doing this? Ive been trying simple things like

if (char = Y)
then bool = true
else
bool = false
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// need to have variables:
char c;
bool b;

c = get_char_from_file_somehow();

 // you can do this...
if(c == 'Y')
  b = true;
else
  b = false;

  // or you can shortcut it with this:
b = (c == 'Y');

Topic archived. No new replies allowed.