باگ یابی به روش جریان آب و سینک

???? ??? ????? ??? ????
- ????? ??: ?? ???? ?? ?? ?? ???? ?? ?????? ?? ?????? ????? ????? ????? ?? ?????.
- ????: ?? ????? ?? ?? ?? ?? ????? ? ?? ????? ??? ???. ????? ?? ??? ?? ???? ??? ?? ???? ???? ????? ???? ????.
???? ???? ???? ??? (??? ??????) ?? ???? ?? ?? ???? ???? ?? ?? ????? ?? ????. ?????? ?? ?? ?? ???? ????? ?? ???? ?? ???? ?? ????? ????? ?? ???.
?????? ???? ?? ??? ?? ?? ??? ??????:
#include <stdio.h>;
#include <stdlib.h>;
#include <string.h>;
void pick_steps(char *ret, const char *buf,
int start, int end, int step)
{
for (int j = 0, i = start; i < end; i += step)
ret[j++] = buf[i];
}
int main(int argc, char **argv)
{
if (argc != 3) {
fprintf(stderr, "%s <sentence> <step>\n", argv[0]);
return 1;
}
char result[200] = {0};
int length = strlen(argv[1]);
if (length >= 200 || length < 1) {
fprintf(stderr,
"Error: sentence should have less than 200 chars.\n");
return 1;
}
int step = atoi(argv[2]);
pick_steps(result, argv[1], 0, length, step);
printf("result: %s\n", result);
return 0;
}
?? ?? ????? ?? ?????? ? ?? ????? ???????? ?? ?? ???? pick_steps ?????? ?? ????. ??? ?? ???? ?? ?????? ????? ???? ??? ?? ???? ????? ???? ??? ?? ????? ?? ????? ?? ??. ??? ???? ?? ???? ???? ??? ?????? step? ?? ?????? ?? ?????? ?? ????? ??????? ??? ?? ??????? ? ?? ??????? ?? ???????.
?? ???? main? ?????? ?? ??? ?????? step ?? ?? ????? ?? ???? ? ?? ?? ???? ???? ?? ??? ?? ??? ?????? ?? ??? ? ?????? ?? ?????? ???? ???? ??? ?? [argv[1 ???? ???? ?? ?? ???? ?????? ?????? ?? ???.
?? ????? ?? ???? ????? ?? ?? ???? ?? ???? ???? ??? ? ?? ??????? ?? ???? ???? ???? ???????? ????? ?? ????? ?????? ? ???????? ???????? ??????.
???? ?? ??? ??? ?? ??? ?????? ??? ???? pick_steps ?? ?? ????? ?? ???? ???? ?? ?? ???? ?? ???? ???? ?????? ???? ???? ??????? ?? ?? ???? ?? ???? ?? ??? ???? ???? ????.
???? :
kaliboys.com
??????? :
??????????





