So I have this code that is supposed to go through a file and seperate Char (' '), String(" "), and Comments then print them and anything that isn't that is a Token. Single-line and multi line are found with /* and */. I have the single line, String, Char and Token part. But I can't seem to figure out the multi line comment.
This is what i have so far:
Code:
void lex(char *line, int start, int end, int length, char *typeN){
   char token[MAXTOKEN];
   while (start <length && isspace(line[start])) {
      start++;
   }
   if (start >=end){
      return;
   }
   strncpy(token, &line[start], end-start);
   token[end-start] = '\0';
   printf("%s: %s\n", typeN, token);
}
void  tokenize(char *line, int length)
{
   int start= 0;
   int end=0;
   static  int inComment=0;
   for (end=0; end <length; end++){
      if(line[end]=='/' && line[end+1]=='*' && line[end+2]=='\n'){
         lex(line, start, end, length, "Token");
         start=end;
         end++;
         inComment=1;
         while(inComment){
            end++;
            if(line[end]=='*' && line[end+1]=='/'){
               inComment=0;
               end+=2;
               lex(line, start, end, length, "Comment");
            }
         }
      }

      else if (line[end]=='/' && line[end+1]=='*') {
         lex(line, start, end, length, "Token");
         start=end;
         end++;
         while(end<length && (line[end]!='*' || line[end+1]!='/')){
            end++;
         }
         end+=2;
         lex(line, start, end,  length, "Comment");
         start=end;
         end++;
         //Finds start of comment. Does Token then goes through comment.
      }
      else if (line[end] == '"') //If double qotes then
      {
         lex(line, start, end, length,"Token");
         start=end;
         end++;
         while(end<length && line[end]!='"')
         {
            end++;
         }
         if (end<length){
            end++;
            lex(line, start, end, length, "String");
            start=end;
            end--;
         }

      }

      //If sees ' then is a char. end++ to enter char until ' then end++ and lex.
      else if (line[end] =='\''){
         end++;
         while(end<length && line[end]!='\''){
            end++;
         }
         end++;
         lex(line, start, end, length, "Char");
         start=end;
         end--;

      }
      //while+lex After anything at start/zero has been tokened. It adds to the index, through the characters. Once it finds the double quote it lexes from start=wherever the last token ended to end+zero to get the ending quotes.

      else if(isspace(line[end])) {
         lex(line, start, end, length, "Token");
         start = end;
         // printf("%i: ", end);
      }
   }
}
A multi-line comment is supposed to look like this

Comment: /*
Comment: multi
Comment: line
Comment: comment */

But this is what it looks like for me

Comment: /*

Token: multi
Token: line
Token: comment
Token: */
Comment: /*

I know i'm supposed to have it see if its in a comment, if it reaches the end of the string and it hasn't found a ending */ then it keeps going. But I'm a little lost and some guidance would be appreciated.