저기 죄송한데 질문하나만 할께요;;; 디버그까지는 잘되다가 리다이렉션을 이용하니까 안되네요 왜이런가요???

mauser87의 이미지

코드는 아래부터이고요;;

#include
#include
#include
#include
#define MAX 20

struct node{
char number[MAX];
char name[MAX];
char phone[MAX];
char mail[MAX];
struct node *ptr;
};

struct node *head, *tail;
void initnode(){
head=(struct node*)malloc(sizeof(struct node));
tail=(struct node*)malloc(sizeof(struct node));
head->ptr = tail;
}

void addnode(char number[],char name[],char phone[], char mail[]){
struct node *newnode, *temp;
int i;
newnode=(struct node*)malloc(sizeof(struct node));

for(i=0;i newnode->number[i] = number[i];
};
newnode->number[i]='\0';

for(i=0;i newnode->name[i] = name[i];
};
newnode->name[i]='\0';

for(i=0;i newnode->phone[i] = phone[i];
};
newnode->phone[i]='\0';

for(i=0;i newnode->mail[i] = mail[i];
};
newnode->mail[i]='\0';


temp = head;
while(temp->ptr!=tail){
temp=temp->ptr;
}
newnode->ptr=tail;
temp->ptr=newnode;

}

void printnode(){
struct node *now;
for(now=head->ptr;now!=tail;now=now->ptr){
fprintf(stdout,"%s\n",now->number);
fprintf(stdout,"%s\n",now->name);
fprintf(stdout,"%s\n",now->phone);
fprintf(stdout,"%s\n",now->mail);
}
}
void erasenode(char dell[]){
struct node *del, *temp;
temp=head;
while(temp!=tail){
del=temp->ptr;
if(strcmp(del->number,dell)==0){
temp->ptr=del->ptr;
free(del);
}
temp=temp->ptr;
}
}

int findnode(char search[]){
int j=0;
struct node *now;
for(now=head->ptr;now!=tail->ptr;now=now->ptr){
if(strcmp(now->number,search)==0){
fprintf(stdout,"[검색 결과\n");
fprintf(stdout,"%s\n",now->number);
fprintf(stdout,"%s\n",now->name);
fprintf(stdout,"%s\n",now->phone);
fprintf(stdout,"%s\n",now->mail);
return 0;
}
};
return fprintf(stdout,"찾으시는 자료가 없습니다.\n");
}
int findnode2(char search[]){
int j=0;
struct node *now;
for(now=head->ptr;now!=tail->ptr;now=now->ptr){
if(strcmp(now->name,search)==0){
fprintf(stdout,"[검색 결과]\n");
fprintf(stdout,"%s\n",now->number);
fprintf(stdout,"%s\n",now->name);
fprintf(stdout,"%s\n",now->phone);
fprintf(stdout,"%s\n",now->mail);
return 0;
}
}
return fprintf(stdout,"찾으시는 자료가 없습니다.\n");
}

int main(){
int ch=0;
int ch2=0;
char number[MAX];
char name[MAX];
char phone[MAX];
char mail[MAX];
char search[MAX];
char del[MAX];
initnode();
while(ch!=5){
fprintf(stderr,"########################################\n");
fprintf(stderr,"### 번호를 선택하세요. ###\n");
fprintf(stderr,"### 1. Inesrt data ###\n");
fprintf(stderr,"### 2. Print Data ###\n");
fprintf(stderr,"### 3. Search Data ###\n");
fprintf(stderr,"### 4. Delete Data by ID ###\n");
fprintf(stderr,"### 5. Quit ###\n");
fprintf(stderr,"########################################\n");
fprintf(stderr,"번호를 입력하세요");
scanf("%d",&ch);
fflush(stdin);
switch(ch){
case 1:
fprintf(stderr,"학번:");
fgets(number,MAX,stdin);
*(number+(strlen(number)-1))='\0';
fprintf(stderr,"이 름:");
fgets(name,MAX,stdin);
fflush(stdin);
*(name+(strlen(name)-1))='\0';
fprintf(stderr,"전화번호:");
fgets(phone,MAX,stdin);
fflush(stdin);
*(phone+(strlen(phone)-1))='\0';
fprintf(stderr,"이메일:");
fgets(mail,MAX,stdin);
fflush(stdin);
*(mail+(strlen(mail)-1))='\0';
fprintf(stderr,"\n");
addnode(number,name,phone,mail);
break;
case 2:
fprintf(stdout,"[신상 정보 출력]\n");
printnode();
break;
case 3:
fprintf(stderr,"########################################\n");
fprintf(stderr,"1. by ID\n");
fprintf(stderr,"2. by name\n");
fprintf(stderr,"3. Cancel\n");
fprintf(stderr,"검색 방법을 선택하세요:");
scanf("%d",&ch2);

switch(ch2){
case 1:
fprintf(stderr,"찾을 데이터 입력:");
fflush(stdin);
fgets(search,MAX,stdin);
*(search+(strlen(search)-1))='\0';
findnode(search);
break;

case 2:
fprintf(stderr,"찾을 데이터 입력:");
fflush(stdin);
fgets(search,MAX,stdin);
*(search+(strlen(search)-1))='\0';
findnode2(search);
break;
case 3:
break;
}
break;
case 4:
printf("삭제할 데이터 입력:");
fflush(stdin);
fgets(del,MAX,stdin);
*(del+(strlen(del)-1))='\0';
erasenode(del);
break;
default:
break;
};
};
return 0;
}

디버그 모드나 빌드 모드에서 잘돌아가는데 명령프롬프트에서 리다이렉션을 이용하니까 에러가 나버립니다.;;;;;

왜이런가요 고수님들 좀 가르쳐 주세요!!!

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.