This is my code :
Expand|Select|Wrap|Line Numbers
- #include <iostream>
- #include <stdio.h>
- #include <stdlib.h>
- const char arr1[] = {'+', '-', '*', '/', '>', '<'};
- bool isOperator(char ch)
- {
- bool res = false;
- if (ch == arr1[0])
- res = true;
- else if (ch == arr1[1])
- res = true;
- else if (ch == arr1[2])
- res = true;
- else if (ch == arr1[3])
- res = true;
- else if (ch == arr1[4])
- res = true;
- else if (ch == arr1[5])
- res = true;
- return res;
- }
- int main()
- {
- char ch;
- do {
- //ch = '\0';
- printf("Enter char.\n");
- scanf("%c", &ch);
- printf("%s\n", (isOperator(ch) ? "true" : "false"));
- }while (ch != 'q');
- return 0;
- }
I tried to put NULL in ch, but that didn't changed the flow.
Can you please check what is going wrong?