Hey everyone, this program's been killing me. I have to create a program that takes another program as input and counts the lines. Pretty simple, except that to do this, you have to count semicolons which means you have to negate semicolons that are comment text or within double quotes. My plan was to simply read the string until you reach the double quote and change everything after the double quote to a NULL character, and I wrote what I believe to be a mostly sound piece of code to do this:
for(counter = 0; counter < 500; counter++)
{
if (select == 0 && buffer[counter] == '"')
{
select = 1;
store = buffer[counter];
}
if (select == 1 && buffer[counter] != '"')
{
buffer[counter] = NULL;
}
if (select == 1 && buffer[counter] == '"' && buffer[counter] != store)
{
select = 0;
}
}
The point of this piece of code is to letter by letter compare each one to the ". Initially, with select set to 0, nothing will change. When the program first encounters a " in the string, select will change to 1, and from there the program will convert every character to a null character until it reaches the next ", at which point, it will set select back to zero. It doesn't appear to be working, though. Anything look wrong with this?