Hey I was wondering if anybody could help me with what is probably a very simple problem.
I am trying to read thru an array that i read from a file XXXXX.cpp
and I'm trying to remove anything that is a comment
and I have removed // comments but i cant remove * comments.
if (array[i]=='')
{
if (array[i+1] =='*')
{
while (array[i] != '*' && array[i+m1] != '')
{
array[i] = ' ';
i++;
}
}
this is a small part of my function where it removes the comment by deleting everything between * and *.
and i get a problem where the '' brings about a unterminated character constant i was wondering if anybody new either a way around this or a better way of doing this.
thanks
Comments
OK sorry i made a stupid mistake in my file before which confused me on slash and back slash.
but i have a very similar question which is how do i search an array for a ' i have tryed to get it using ''' but that was clearly not going to work and evidently didn't
so if somebody knows of a way to search an array for ' then i would be very grateful
: OK sorry i made a stupid mistake in my file before which confused me on slash and back slash.
:
: but i have a very similar question which is how do i search an array for a ' i have tryed to get it using ''' but that was clearly not going to work and evidently didn't
: so if somebody knows of a way to search an array for ' then i would be very grateful
:
I don't understand. Please reexplain.
but i can't search thru
if(array[i] == ''')
because it gives me errors
so I'm asking if there is another fairly basic way to search for an single quotation within a char array
: but i can't search thru
: if(array[i] == ''')
: because it gives me errors
: so I'm asking if there is another fairly basic way to search for an single quotation within a char array
:
Sorry, I can't get around the problem eiter. Try replacing single quotes with double quotes in the array or another substitute if possible as a way of getting around this problem. I hope this helps.
[b][red]This message was edited by PatLDDD at 2002-10-19 20:15:22[/red][/b][hr]
: : sorry what I am trying todo is find the single quotations in an array (')
: : but i can't search thru
: : if(array[i] == ''')
: : because it gives me errors
: : so I'm asking if there is another fairly basic way to search for an single quotation within a char array
: :
:
: Sorry, I can't get around the problem eiter. Try replacing single quotes with double quotes in the array or another substitute if possible as a way of getting around this problem. I hope this helps.
:
Hello,
You should go with
if( array[i] == ''' )
// Do somethig constructive
Yes, you must put a before the char you whant to check...
It's not always the case but there are some exception like :
' and and there is probably more.
Pat