Presentation Error

seokma97 Reply 9 years 3 weeks ago
#include <stdio.h> char verse_line[100000]; char line[1000]; int index; int getline(){ char ch; int i=0; while((ch=getchar())!=EOF){ if (ch=='\n') break; line[i++] = ch; } line[i] = '\n'; return i; } void copy_line(int len){ for (int i=len;i>=0;i--){ verse_line[index++] = line[i]; } } int main() { int len; index = 0; while ((len = getline()) > 0){ copy_line(len); } printf("%s",verse_line); return 0; } 자꾸 Presentation Error가 발생합니다. 에러가 나는 이유를 잘 모르겠습니다.
booksky Reply 9 years 3 weeks ago
안녕하세요. 조교 이은헌입니다. presentation error가 뜨는 이유는, \n까지 reverser를 해버린 까닭에 sample input을 예로 들어 설명하면 At vero eos et accusamus et iusto otsui te sumasucca te soe orev tA odio dignissimos ducimus, qui blanditiis siitidnalb iuq ,sumicud somissingid oido praesentium voluptatum deleniti itineled mutatpulov muitnesearp 이런 현상이 벌어질 것입니다. \n까지 뒤집었기 때문에 시작이 \n으로 시작해서 한칸을 띄고 문장이 시작되는 것이지요. 시작을 \n으로 시작하지 않도록 수정하시면 될 것 같습니다.
seokma97 Reply 9 years 3 weeks ago
감사합니다^^.