Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int GetCommentsNumber(FILE* inputFile)
- {
- int numberOfComments = 0;
- int multylineComment = 0;
- char line[256];
- char currentChar;
- while ((currentChar = fgetc(inputFile)) != EOF) //Chete dokato ne stingne krai na faila
- {
- int i = 0;
- while (currentChar != '\n' && currentChar != EOF)//Prochite 1 red
- {
- line[i++] = currentChar; //Zapisva v line
- currentChar = fgetc(inputFile);
- }
- line[i] = '\0';
- if (i != 0) //Ima procheten red
- {
- for (size_t j = 0; j < i - 1; j++)
- {
- if (line[j] == '/' && multylineComment == 0)
- {
- if (line[j + 1] == '/')
- {
- numberOfComments++;
- }
- else if (line[j + 1] == '*')
- {
- multylineComment = 1;
- }
- }
- else if (line[j] == '*' && line[j + 1] == '/')
- {
- multylineComment = 0;
- numberOfComments++;
- }
- }
- }
- }
- rewind(inputFile);
- return numberOfComments;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement