Do you really understand certain grammars in C language learning

Written before: I have
watched a video of a big guy. He thinks about the learning and understanding of the C language. Most of the learning is based on grammar learning. There are also some frameworks. If you are really proficient in C language, you can learn memory. This part of the "Introduction to Computer Science" is of great help.

Test your grammatical proficiency:
Title:
The result of the following code is:

#include<stdio.h>

int main()
{
    
    char *s="12134211";
 int v[4]={
    
    0,0,0,0},k,i;
 for(k=0;s[k];k++)
   {
    
    switch(s[k])
        {
    
    case '1':i=0;
          case '2':i=1;
          case '3':i=2;
          case '4':i=3;}
    v[i]++;
   }
 for(k=0;k<4;k++) 
	 printf("%d",v[k]);
 printf("\n");
}

Options:
4 2 1 1 0 0 0 8
4 6 7 8 8 8 8 8

At the beginning I got 4678, and I was very proud that I didn't notice the break; but I didn't know that some details were overlooked. i is continuously assigned and incremented based on the last one, and then output.
Someone also got 4211. Obviously there are many aspects that can be tested on this question

The answer is the result of its own operation. Hehehe

Guess you like

Origin blog.csdn.net/yooppa/article/details/114980945