Skip to content

Check Number of lines #8

@LeandroMartinsdS

Description

@LeandroMartinsdS

Check the number of lines in file to confront with the maximum defined of macro definition.

The following approach can be investigated further

int countLines(int *lineNum, char *filename)
{
    char cmd[512];
    sprintf(cmd,"wc -l < %s", filename);

    FILE *pipe = popen(cmd,"r");
    if(pipe == NULL) {
        perror("popen failed");
        return 1;
    }

    if(!(fscanf(pipe,"%d",lineNum))){
        perror("fscanf failed");
        pclose(pipe);
        return 1;
    }

    pclose(pipe);
    return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions