could someone please explane what a pars error is in C++?

Thank your consideration.
Dick

Recommended Answers

All 3 Replies

hey,
may be you should post the code that generated the error

here is the code sorry!

// Print_it.c-This program prints a listing with line numbers!
#include <stdlib.h>
#include <stdio.h>
void do_heading(char *filename);
int line = 0, page = 0;
int main( int argv, char *argc[])
{
    char buffer[256];
    FILE *fp;
    if(argv < 2 )
    {
       fprintf(stderr, "\nProper Usage is: " );
       fprintf(stderr, "\nprint_it filename.ext\n" );
       return(1);
    }
    if (( fp = fopen( argc[1], "r" )) == NULL )
    {
       fprintf( stderr, "Error opening file. %s!", argc[1]);
       return(1);
    }
    page = 0;
    line = 1;
    do_heading( argc[1]);
    while( fgets( buffer, 256, fp ) ! == NULL )
    {
       if( line % 55 == 0 )
          do_heading( argc[1] );
          fprintf(LPT1, "%4d:\t%s", line++. buffer );
     }
     fprintf( LPT1, "\f" );
     fclose(fp);
     return 0;
}
void do_heading( char *filename )
{
     page++;
     if ( page > 1)
        fprintf( LPT1, "\f" );
     fprintf( LPT1, "Page: %d, %s\n\n", page, filename );
}

These are compiler errors

30 c:\dev-c_~1\print_it.c
 parse error before `!'
35 c:\dev-c_~1\print_it.c
 `LPT1' undeclared (first use in this function)
35 c:\dev-c_~1\print_it.c
 (Each undeclared identifier is reported only once
35 c:\dev-c_~1\print_it.c
 for each function it appears in.)
35 c:\dev-c_~1\print_it.c
 request for member `buffer' in something not a structure or union
38 c:\dev-c_~1\print_it.c
 parse error before string constant
38 c:\dev-c_~1\print_it.c
 warning: data definition has no type or storage class
39 c:\dev-c_~1\print_it.c
 warning: parameter names (without types) in function declaration
39 c:\dev-c_~1\print_it.c
 warning: data definition has no type or storage class

40 c:\dev-c_~1\print_it.c
 parse error before `return'
48 c:\dev-c_~1\print_it.c
 `LPT1' undeclared (first use in this function)

while( fgets( buffer, 256, fp ) ! == NULL )

This is an error. Most like it you want !=

fprintf(LPT1, "%4d:\t%s", line++. buffer );

LPT1 is suppost to be a file open already and declared. Compiler
do not have knowledge of what LPT1 is.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.