presentation error

baio2033 Reply 7 years 5 weeks ago
이유를 모르겠습니다.. #include <stdio.h> #include <string.h> int main() { char str[1000]; char* rstr; int len; int i,j; int count = 0; // c = getchar(); while (fgets(str,1000,stdin)) { len = strlen(str); for (i = 0; i < len; i++) { if (str[i] == "\t") { j = i - 1; count = 0; for (int num = 0; num < 4; num++) { if (str[j] == " ") count++; j--; } if (count == 0) { str[i] = " "; } else if (count == 1) { str[i] = " "; } else if (count == 2) { str[i] = " "; } else if (count == 3) { str[i] = " "; } } } printf("%s", str); } return 0; }
withcs1 Reply 7 years 5 weeks ago
공백4개탭1a넣어보세요 탭은 4단위로 이동합니다. 이전문자가 공백인지를 찾고계신데 입력받은 탭이 라인에서 몇번째 문자인지를 찾으셔야합니다.