Checking Multiple Values in if() statement
hey guys i keep going off and on with my programming resulting in my forgeting how to do most everything :p
ok so the program im working on is supposed to display all the ascii characters and their value I do not want to show the values that do not contain an ascii character (7,8,9,10,13,32) and i remember how to check the index for multiple values in a switch() but i think i remember doing it all in an if() statement but i cant remember what the correct syntax is for that.
i was trying this
Code:
if(1 == 7 || 8 || 9 || 10 || 13 || 32) i++
anyways ill post my code and if you can help me out that would be great Thanks
Code:
#include <iostream>
using namespace std;
int main()
{
cout<<"Here we go!\n";
char var1 = 55;
cout<<"\nvar1 is "<<var1<<endl;
cout<<"the size of Var1 is: "<<sizeof(var1);
for(unsigned char i =0; i<255; i++)
{
switch(i) //how to check i for multiple values in if statement
{
case 7: i++;
case 8: i++;
case 9: i++;
case 10: i++;
case 13: i++;
case 32: i++;
}
printf("%d %c",i, i); // How to display same results in c++ !c
cout<<endl;
}
system("pause");
}//end main
i also have another question, How would i get the same result the printf() statement has using cout?