??????????????????5
???????????? ???????[ 2013/8/8 15:08:32 ] ????????
???????????: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;
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11