???????????:gcc-o testgcov -ftest-coverage -fprofile-arcs testgcov.c

????./testgcov--->??г????????????佫??д??testgcov.gcda??testgcov.gcno??

????gcov-b testgcov.c --->testgcov.c.gcov???????????

????testgcov.c.gcov ??????:

-: 0:Source:testgcov.c
-: 0:Graph:testgcov.gcno
-: 0:Data:testgcov.gcda
-: 0:Runs:1
-: 0:Programs:1
-: 1:/*Program: testgcov.c -- interpert the workflow of gcov */
-: 2:#include<stdio.h>
1: 3:int main(){
1: 4: printf("Hello??World ");
1: 5:}

?????:gcov -b???????е?????-f???????????е??????

????2.3.3gcov?????????t???

/*Program:autosell.c -- design the input test case and get the code coverage of program */
#include<stdio.h>
void welcome();
void nochange(int num5coins);
void getcoin(int *coin);
void pushbutton(int *button);
void process(int* coin??int* button??int* num5coins);
int main(){
 int coin=0??button=0??num5coins=2;
 int i;
 for(i=0;i<10;++i){
  welcome();
  nochange(num5coins);
  getcoin(&coin);
  pushbutton(&button);
  process(&coin??&button??&num5coins);
 }
 return 0;
}
void welcome(){
 system("clear");//library function??which
 printf("welcome to this auto selling machine! ");
}
void nochange(int num5coins){
 if(num5coins == 0)
  printf("No change now! ");
}
void getcoin(int* coin){
 int flagredo;
 do{
  printf("Please pitch your coin(5-5???10-1?):");
  scanf("%d"??coin);
  if(*coin!=5 && *coin!=10){
   printf("Wrong coin!Return this coin. ");
   flagredo=1;
  } else
   flagredo=0;
 }while(flagredo);
}
void pushbutton(int *button){
 int flagredo;
 do{
  printf("Please select your drink(1-orange juice??2-beer):");
  scanf("%d"??button);
  if(*button!=1 && *button!=2){
   printf("Wrong input??Please re-select. ");
   flagredo=1;
  } else
   flagredo=0;
 } while(flagredo);
}
void process(int* coin??int* button??int* num5coins){
 if(*coin == 10 && *num5coins ==0){
  printf("No change! ");
   printf("Return 1 yuan coin. ");
 } else {
  if(*coin == 10){
   if(*button ==1)
    printf("Please take your orange juice. ");
   else
    printf("Please take you beer ");
   (*num5coins)--;
   printf("Return 5 jiao coin. ");
  }
  if(*coin == 5){
   if(*button ==1)
    printf("Please take your orange juice. ");
   else
    printf("Please take you beer ");
   (*num5coins)++;
  }
 }
 printf(" Press Enter to continue");
 getchar();getchar();

 *coin =0;
 *button=0;
}