C PROGRAMMER TEST 
Author Message
 C PROGRAMMER TEST

                 C PROGRAMMER TEST

1. Create a text file named "parse.dat containing the following lines.

              lookup_rec("db_test",bo_test,11")
              dial ("95551212")
              printxy(10,3,0,15,GREY,"testing")

2. Your task is to:

     a) Open the above file, reading in one line at a time.

     b) Display the line before parsing.

     c) Parse th eline into the format as described below.

     d) Pause the waiting for the enter key to bring in the next line of
        the file.

     e) Repeat the process until you've parsed each line of the file.

 Each line is a command followed by a parenthesized comma-delimited
 parameter list.

 Each parameter has a type. Types are defined as: String, Variable or  
 Numeric.

 For example, the output for line 1 should look like the following:

               lookup_rec("db_test",bo_test,11)

               Command:       lookup_rec
               Parameter1:    db_test       Type: String
               Parameter2:    bo_test       Type: Variable
               Parameter3     11            Type: Numeric

3. Include comments to define limitations or assumptions.

4. Any errors encountered should be displayed. Provide as much error
   checking as you feel is appropriate. Your program should not core-dump
   or lock up no matter what the data is that you are given.

5. Your program should be able to handle other text files with data in
   this format to produce the required output.

6. Use standard ANSI C constructions and functions except for one: You
   are not allowed to use strok.

        I WILL POST THE ANSWER IN A COUPLE DAYS.....GOOD LUCK



Wed, 05 Jan 2000 03:00:00 GMT  
 C PROGRAMMER TEST

                 C PROGRAMMER TEST

1. Create a text file named "parse.dat containing the following lines.

              lookup_rec("db_test",bo_test,11")
              dial ("95551212")
              printxy(10,3,0,15,GREY,"testing")

2. Your task is to:

     a) Open the above file, reading in one line at a time.

     b) Display the line before parsing.

     c) Parse th eline into the format as described below.

     d) Pause the waiting for the enter key to bring in the next line of
        the file.

     e) Repeat the process until you've parsed each line of the file.

 Each line is a command followed by a parenthesized comma-delimited
 parameter list.

 Each parameter has a type. Types are defined as: String, Variable or  
 Numeric.

 For example, the output for line 1 should look like the following:

               lookup_rec("db_test",bo_test,11)

               Command:       lookup_rec
               Parameter1:    db_test       Type: String
               Parameter2:    bo_test       Type: Variable
               Parameter3     11            Type: Numeric

3. Include comments to define limitations or assumptions.

4. Any errors encountered should be displayed. Provide as much error
   checking as you feel is appropriate. Your program should not core-dump
   or lock up no matter what the data is that you are given.

5. Your program should be able to handle other text files with data in
   this format to produce the required output.

6. Use standard ANSI C constructions and functions except for one: You
   are not allowed to use strok.

        I WILL POST THE ANSWER IN A COUPLE DAYS.....GOOD LUCK



Wed, 05 Jan 2000 03:00:00 GMT  
 C PROGRAMMER TEST

Quote:

>                 C PROGRAMMER TEST

>1. Create a text file named "parse.dat containing the following lines.

>              lookup_rec("db_test",bo_test,11")
>              dial ("95551212")
>              printxy(10,3,0,15,GREY,"testing")

>2. Your task is to:

>     a) Open the above file, reading in one line at a time.

>     b) Display the line before parsing.

>     c) Parse th eline into the format as described below.

>     d) Pause the waiting for the enter key to bring in the next line of
>        the file.

>     e) Repeat the process until you've parsed each line of the file.

Do your own f__king homework.


Fri, 07 Jan 2000 03:00:00 GMT  
 C PROGRAMMER TEST

OK, here's my answer...

extern void and _a_miracle_happens(void);

int main (void){
   and_a_miracle_happens( );

Quote:
}

Greg
Quote:

>                 C PROGRAMMER TEST

>1. Create a text file named "parse.dat containing the following lines.

>              lookup_rec("db_test",bo_test,11")
>              dial ("95551212")
>              printxy(10,3,0,15,GREY,"testing")

>2. Your task is to:

>     a) Open the above file, reading in one line at a time.

>     b) Display the line before parsing.

>     c) Parse th eline into the format as described below.

>     d) Pause the waiting for the enter key to bring in the next line of
>        the file.

>     e) Repeat the process until you've parsed each line of the file.

> Each line is a command followed by a parenthesized comma-delimited
> parameter list.

> Each parameter has a type. Types are defined as: String, Variable or  
> Numeric.

> For example, the output for line 1 should look like the following:

>               lookup_rec("db_test",bo_test,11)

>               Command:       lookup_rec
>               Parameter1:    db_test       Type: String
>               Parameter2:    bo_test       Type: Variable
>               Parameter3     11            Type: Numeric

>3. Include comments to define limitations or assumptions.

>4. Any errors encountered should be displayed. Provide as much error
>   checking as you feel is appropriate. Your program should not core-dump
>   or lock up no matter what the data is that you are given.

>5. Your program should be able to handle other text files with data in
>   this format to produce the required output.

>6. Use standard ANSI C constructions and functions except for one: You
>   are not allowed to use strok.

>        I WILL POST THE ANSWER IN A COUPLE DAYS.....GOOD LUCK



Fri, 07 Jan 2000 03:00:00 GMT  
 C PROGRAMMER TEST

:                  C PROGRAMMER TEST

: 1. Create a text file named "parse.dat containing the following lines.

:               lookup_rec("db_test",bo_test,11")
:               dial ("95551212")
:               printxy(10,3,0,15,GREY,"testing")

: 2. Your task is to:

:      a) Open the above file, reading in one line at a time.
:      
:      b) Display the line before parsing.

:      c) Parse th eline into the format as described below.

:      d) Pause the waiting for the enter key to bring in the next line of
:         the file.

:      e) Repeat the process until you've parsed each line of the file.

:  Each line is a command followed by a parenthesized comma-delimited
:  parameter list.

:  Each parameter has a type. Types are defined as: String, Variable or  
:  Numeric.

:  For example, the output for line 1 should look like the following:

:                lookup_rec("db_test",bo_test,11)

:                Command:       lookup_rec
:                Parameter1:    db_test       Type: String
:                Parameter2:    bo_test       Type: Variable
:                Parameter3     11            Type: Numeric

: 3. Include comments to define limitations or assumptions.

: 4. Any errors encountered should be displayed. Provide as much error
:    checking as you feel is appropriate. Your program should not core-dump
:    or lock up no matter what the data is that you are given.

: 5. Your program should be able to handle other text files with data in
:    this format to produce the required output.

: 6. Use standard ANSI C constructions and functions except for one: You
:    are not allowed to use strok.

:         I WILL POST THE ANSWER IN A COUPLE DAYS.....GOOD LUCK

Here is my answer in Perl.  I don't think it would be appropriate to
post the answer in C for an obvious homework question.  You'll learn
more by doing your own homework. :-)

#!/usr/local/bin/perl -w
require 5.003;
use strict;


    print STDERR "Usage : $0 <file>\n";
    exit 0;

Quote:
}

open FILE, "<$ARGV[0]" or die "$!";
while(<FILE>) {

    $i = 0;
    unless(/^\s*\w+\s*\([^)]*\)\s*;?\s*$/) {
        print "Malformed input line\n\n";
        next;
    }
    ($name) = $_ =~ /(\w+)\s*\(\s*/;
    $tmp = $';
    for(;;) {
        ($arg) = $tmp =~ /([^,)]+)[,)]/;
        last unless defined $arg;
        $tmp = $';
        $tmp =~ s/^,/ ,/;
        $arg =~ s/^\s+//;
        $arg =~ s/\s+$//;

        if($arg =~ /^".*"$/) {
            $args[$i][0] = 'STRING LITERAL             ';
        }
        elsif($arg =~ /^[-+]?\d+$/) {
            $args[$i][0] = 'INTEGER CONSTANT           ';
        }
        elsif($arg =~ /^[a-zA-Z]\w*$/) {
            $args[$i][0] = 'VARIABLE                   ';
        }
        elsif($arg =~ /^('\\[xX][a-fA-F0-9]{2}'|'.'|'\\0'|'\\[0-7]{3}')$/) {
            $args[$i][0] = 'CHARACTER CONSTANT         ';
        }
        elsif($arg =~ /^[-+]?(\d+\.\d+$)|(\d\.\d+[eE][+-]\d{2}$)/) {
            $args[$i][0] = 'FLOATING POINT CONSTANT    ';
        }
        else {
            $args[$i][0] = 'HMM, WE HAVE A PROBLEM HERE';
        }
        $args[$i++][1] = $arg;
    }
    print $_;
    print 'FUNC                        : ',$name,"\n";


    }
    getc;

Quote:
}

close FILE;

exit 0;

--

    No, I am not going to explain it.  If you can't figure it out, you
    didn't want to know anyway...  -- Larry Wall, 1991



Fri, 07 Jan 2000 03:00:00 GMT  
 C PROGRAMMER TEST


Quote:
>                 C PROGRAMMER TEST

>1. Create a text file named "parse.dat containing the following lines.

I would try the comp.homework.c newsgroup.


Sat, 08 Jan 2000 03:00:00 GMT  
 C PROGRAMMER TEST

Please tell me that you already had that program sitting on your desktop
and you didn't write it just for the fun of it.

Jay



Sat, 08 Jan 2000 03:00:00 GMT  
 C PROGRAMMER TEST

Quote:

> Here is my answer in Perl.  I don't think it would be appropriate to
> post the answer in C for an obvious homework question.  You'll learn
> more by doing your own homework. :-)

[awesome Perl program snipped]

OTOH he can learn a lot about Perl by looking at your answer to his
homework question :-)

Did you write all that Perl code just to show him how to do it ?
If so: Wow !

Stephan
(initiator of the campaign against grumpiness in c.l.c)



Sun, 09 Jan 2000 03:00:00 GMT  
 C PROGRAMMER TEST

Quote:

>                  C PROGRAMMER TEST

s/TEST/HOMEWORK/ ?


Mon, 10 Jan 2000 03:00:00 GMT  
 C PROGRAMMER TEST


: >                 C PROGRAMMER TEST

                    C PROGRAMMER CHEAT
                    C PROGRAMMER FAIL
                    C PROGRAMMER WEEP

--
 - Wayne A. King





Tue, 11 Jan 2000 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Non-CS major C programmers

2. Newbie: separate big .cs file into small .cs files

3. test test test test

4. Need help of C(/C++) programmer: for porting a tiny Java benchmark test to C(/C++)

5. Samples to test C programmer proficience

6. C PROGRAMMER TEST...CAN YOU CODE THIS??

7. Test for good C programmers.

8. How to test a programmer

9. testing programmers

10. test...test...test

11. Q) Programmer Productivity tips for C programmers ?

12. Looking for C Programmer/Analyst and VB Programmer

 

 
Powered by phpBB® Forum Software