하..링크드리스트. 제가 실습하고 디버깅 하면서 나오는 주소에러

익명 사용자의 이미지


일단 프로그램은 잘돌아갑니다

알고리즘은

파일을 읽기모드로 열어서
링크드리스트로 연결된 리스트들 출력 (current 포인터,head,tail 더미노드이용 )

리스트 목록 사람들 보여주고

여기서 사람을 추가화기위해 새로입력받은후
텍스트 파일에다가 저장

그리고 다시 이를 꺼내서 링크드리스트를 1 부터 k까지 다시 저장!
근데 여기서 문제가 발생
잘 입력되다가 1 2 3 4
여기서 만약 5 라인이 추가된 라인이면
1 2 3 4 1 이렇게 파일에 저장...

디버깅 해서 주소까지 다따서 확인해본결과

currren -> next 가 가리켜야할 것과 tail preview 가 가리키는 것이 같아야하는데!!!
current -> next의 주소와 테일 프리뷰 주소가 다르고

그리고 next에는 변수 1값이 tail ㅔpreview 에는 5가 정상적으로들어감..

이거 왜이러나요 아래는 코드 입니다\
printf("______________________________________\n");

p = fopen("student.db", "r");

sStr = end(p);// 크기 배정후 주소 넘김

fgets(str, sizeof(str), p); // 목록 입력 사항먼저 출력해주자!
printf(str);


while (fgets(sStr,sizeof(char)*1000,p)!=NULL) {

lInsert(p, &list,sStr); //파일에 들어있는 내용 저장
listPrint(&list);

}

while (list.cur != list.head) {
newnode = list.cur;
list.cur = list.cur->prev;
free(newnode);
}

free(list.head);
free(list.tail);

fclose(p);

이후
이어쓰기 함수가 이어지고 그담으로
링크드를 다시연결해서 출력
p = fopen("student.db", "r");

sStr = end(p);// 크기 배정후 주소 넘김

fgets(str, sizeof(str), p); // 목록 입력 사항먼저 출력해주자!

list.numOfStd=0;
list.cur=NULL;

while (fgets(sStr,sizeof(char)*1000,p)!=NULL) {

lInsert(p, &list,sStr); //파일에 들어있는 내용 저장
listPrint(&list);


}

익명 사용자의 이미지

고수분들 ... 저를구원해줏세요/..

익명 사용자의 이미지

일단 코드는

<code> 태그로 감싸서 이렇게 올려 주시고

lInsert와 listPrint 함수는 어디 있나요?

익명 사용자의 이미지

리스트는 역시 그림그려가면 서해야대내요... 해결했습니다. ㅜ.ㅜ.ㅜ 4시간만에 ㅜㅠㅜ
원인은 1234 12345 이렇게 노드가생성되네요... 그러니 마지막에 1을가리키지 하 ㅜㅜㅜ

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.