| T.R | Title | User | Personal Name
 | Date | Lines | 
|---|
| 5606.1 | This one is just too easy | VESPER::VESPER | OpenGL Alpha Geek | Tue Apr 22 1997 08:20 | 9 | 
|  | >    Here's one from my colleage at work :
                        ^^^^^^^^
Keyword mispelled, should be colleague.
:-)
Andy V
 | 
| 5606.2 | Look Around -- You Have Several Thousand Questions Here... | XDELTA::HOFFMAN | Steve, OpenVMS Engineering | Tue Apr 22 1997 10:29 | 15 | 
|  |     
:    if you have any Quiz that test one's understanding on C, please post
:    them here. thanks.
   I'll assume you are looking to create a document or test for a
   customer.  If so, this is the older VAX C notes conference, but
   it contains *piles* of C questions from internal and external folks.
   Also of interest will be the more current DEC C notes conference (at
   TURRIS::DECC).  All manner of obvious -- and obscure -- questions can
   be found here in these conferences.
   One of the most common (subtle) C programming errors is this:
	x[i++] = y[i];
 | 
| 5606.3 | quiz to enhance your C-skill | HANDVC::STEVELIU |  | Wed Apr 23 1997 04:26 | 36 | 
|  |     
    
    
    
    Yes, x[i++] = y[i] is a good one.
    
    Very nice, this is exactly my intention, anyone put up a quiz which can
    trap common errors made by C programmers, it is fun and educational.
    
    Here's another quiz from my colleague :
    
           memory content by byte (all in Hexidecimal)
    
           address      content
           81009040      8A
           81009041      7D
           81009042      45    <-   x is pointing at here
           81009043      3A
           81009044      6F
           81009045      33
           81009046      2B
           81009047      8E
           81009048      22
    
            short *x;      (assume data type of short is 2 bytes long)
    
          After executing a statement of "x = x+1;",
          what is the byte value pointed by x in hexidecimal?        ____________
    
          Then after "further" executing a statement of "x++;",
          what is the byte value pointed by x in hexidecimal?        ____________
    
    
        Anyone can contribute and make this fun.
    
    -sl.
 | 
| 5606.4 |  | CXXC::REINIG | This too shall change | Wed Apr 23 1997 09:44 | 122 | 
|  | From the comp.lang.c faq:  (see TURRIS::DECC note 510
2.9:    I came across some "joke" code containing the "expression"
	5["abcdef"] .  How can this be legal C?
2.11:   How do I write functions which accept 2-dimensional arrays when
	the "width" is not known at compile time?
2.13:   How can I dynamically allocate a multidimensional array?
3.1:    Why doesn't this fragment work?
		char *answer;
		printf("Type something:\n");
		gets(answer);
		printf("You typed \"%s\"\n", answer);
3.2:    I can't get strcat to work.  I tried
		char *s1 = "Hello, ";
		char *s2 = "world!";
		char *s3 = strcat(s1, s2);
based on 3.5.  What's wrong with.
	struct list *p, *base, *last;
	for(p = base; p != last; p = p->next) {
	    free(p);
	}
    Hint: There's more than thing that's wrong.
4.2.  What should the following print:
		int i = 7;
		printf("%d %d\n", i++, i++);
5.4.  Write a STR macro that stringizes it's argument.
	    #define OP plus
	    char *opname = STR(OP)
      should set opname to "plus"
5.5:    What's the difference between "char const *p" and
	"char * const p"?
5.6:    Why can't I pass a char ** to a function which expects a
	const char **?
	Come up with a example to show why it would be bad to allow
        this.  (I've seen the example several times and it always 
        takes me a long time to figure it out again.)
5.7:    My ANSI compiler complains about a mismatch when it sees
                extern int func(float);
                int func(x)
                float x;
                {...
    
        why?
5.8:    Why does the declaration
                extern f(struct x {int s;} *p);
        give me an obscure warning message about "struct x introduced in
        prototype scope"?
5.13:   What is the difference between memcpy and memmove?
9.9:    What is the size of the following structure (as reported by sizeof)
        struct S {
            int x;
            char y;
        }
        (you'll want to say something at the top of the QUIZ about
         the alignment requirements of your C compiler)
4.5:  What's the value of c?
        main(void) {
            int x = 1000000;
            int y = 1000000;
            long z = x * y;
            printf("%d\n", z);
        }
        (at the top of the quiz you'll want to state what CHAR_MIN,
          CHAR_MAX, SHORT_MIN, SHORT_MAX, INT_MIN, INT_MAX, LONG_MIN,
          LONG_MAX)
10.3  Declare a structure which contains a pointer to itself.
      Declare two structures, each of which contains a pointer to the
        other.
11.1:   Why doesn't this code:
                char c;
                while((c = getchar()) != EOF)...
        work?
        
            
 | 
| 5606.5 | What is wrong with this code? | CXXC::PHILLIPS |  | Wed Apr 23 1997 13:35 | 17 | 
|  | 
char c1=1;
char c2=2;
char c3=3;
char *cptr = &c1;
main(){
   if (*cptr++=1)
       if(*cptr++=2)
           if(!(*cptr++=5))
               printf("It worked\n");
   else
       printf("How did we get here?\n");
   printf("%d %d %d\n", c1, c2, c3);
}
 | 
| 5606.6 | quiz->think %s | HANDVC::STEVELIU |  | Fri Apr 25 1997 05:51 | 7 | 
|  |     
    Re: .4 and .5
    
    this is really getting interesting, keep on posting ! I'll write up
    more later.
    
    -steve
 | 
| 5606.7 |  | CSC32::HENNING | A rose with no thorns | Thu May 01 1997 14:27 | 3 | 
|  |     Check out "The C Puzzle Book" by Alan Feuer (ISBN 0-13-115502-4).  He
    formulated the puzzles to demonstrate the ambiguity and complexity of
    the C language.  Good teaching tool!
 |