-2
I’m having trouble knowing how to develop a function that via command line will count and display the amount of commented lines of another program in . c, for example:
Counter Programexample. c -c
The -c argument will call run the function to count the line, any other argument will report invalid.
However it is necessary to do in different files what I have done is this. This function has other arguments, but the important thing is only the line count (this function is so pq was the "recommended" in the work).
Comments that can be counted have to be of a line // or block /* */ those that are after some other action need not be counted, for example:
// prints hello <-- This account
printf ("hello world"); // this is a hello world <<-- this does not need to count
/* hello world */ <-- This account
Filing cabinet: Libcodecount. c
/* ****************************************************
* Função para contar Quantidade de linhas comentadas *
* de um arquivo .c lido *
******************************************************/
#include <stdio.h>
#include "LibCodeCount.h"
void ccRun(char* file, int* nLines, int* nLinesComent, int* nLinesEmpty, int noComment, int silent)
{
}
Filing cabinet Libcodecount. h
/* ********************************************
* Cabeçalho Header da função LibCodeCount.c *
******************************************** */
void ccRun(char* file, int* nLines, int* nLinesComent, int* nLinesEmpty, int noComment, int silent);
Filing cabinet Maincodecount. c
/* *********************************************************
* Função Main que irá executar o programa para a contagem *
* de linhas comentadas de outro arquivo em C *
***********************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "LibCodeCount.h"
int main(int argc, char *argv[])
{
}
After the right function, then I will generate a . exe that when running in Dos along with argument and file will show the amount of commented lines.
I already sought to read about Argc and Argv found it a little confusing, but I would like a more advanced support even.
Thanks for your help.
It seems to me that you need to divide the problem into smaller parts, and if that is the case go asking about the specific problems you are encountering. For example, start by learning to (or asking about) read the arguments passed to the executable; then, how to read a disk file and process by line, and so on. Your current question asks someone to solve the whole task for you.
– bfavaretto
I posted the question so believing that it could help the person to answer my problem, it may seem that I want the whole task, but I really wanted to understand the steps to just create the function of reading commented lines.
– phpricardo