is that right to use if statement to check....
inFile.open(FileName,ios::in);
inData.get(Ch);
if(Ch=='//') //Q?? check the source begin with '//'
{
......
}
source:
//some command;
is that right to use if statement to check....
inFile.open(FileName,ios::in);
inData.get(Ch);
if(Ch=='//') //Q?? check the source begin with '//'
{
......
}
source:
//some command;
i think its ok to use if statements, i dont know how else you are going to check..
>>if(Ch=='//')
in char datatypes ( == ) work for just one char not 2
You'll have to use probably
inData.get(Ch,2,'\n');
and then use strcmp to check
if((strcmp(ch,"\\")==0)
{
---
---
}
-
the first \ is the is the escape operator as which allows you to use \n to mean newline or \t to mean tab or \b to mean backspace or \* to mean start of comment section, etc. Therefore to test to see if there is a single \ in a string or if it is stored in a char variable you need to say something like:
char ch == //whatever;
if(ch == '\\')
However, I don't think the same holds for /. Otherwise you couldn't use the / as indicative of division operator. Therefore // should be a string of two / and can't be evaluated using the == operator but will need to checks for chars or strcmp().