수다닷컴

  • 해외여행
    • 괌
    • 태국
    • 유럽
    • 일본
    • 필리핀
    • 미국
    • 중국
    • 기타여행
    • 싱가폴
  • 건강
    • 다이어트
    • 당뇨
    • 헬스
    • 건강음식
    • 건강기타
  • 컴퓨터
    • 프로그램 개발일반
    • C언어
    • 비주얼베이직
  • 결혼생활
    • 출산/육아
    • 결혼준비
    • 엄마이야기방
  • 일상생활
    • 면접
    • 취업
    • 진로선택
  • 교육
    • 교육일반
    • 아이교육
    • 토익
    • 해외연수
    • 영어
  • 취미생활
    • 음악
    • 자전거
    • 수영
    • 바이크
    • 축구
  • 기타
    • 강아지
    • 제주도여행
    • 국내여행
    • 기타일상
    • 애플
    • 휴대폰관련
  • 프로그램 개발일반
  • C언어
  • 비주얼베이직

외부 데이터에 의해서 출력하는 건데 ..

내꽃

2023.04.01

함수에 의해서 돌아가는 프로그램입니다.
워닝 2개만 뜨고 작동은 되는데요
in_data 에 의해 받은 내용을 out_data 로 파일을 바꿔 줘야 하는데
머가 잘못 대었는지 out_data 에는 아무것도 안남네요.

저장되는 폴더에 in_data 넣었는데도 이렇네요..머가 잘못되어서 out_data로 출력이 안되는지 봐주셧음 합니다.

함수 순서는
input_data 입력
caculation 계산
print 출력
입니다
질문 내용 :
#includestdio.h
#includestdlib.h
int Input_data(struct products *others);
int caculation(struct products *others);
int print(struct products *others);

struct products
{
char name[10]; // 품명
int price; // 단가
int volume; // 수량
int prices; // 금액
double discount_price; // 할인액
double real_price; // 지불액
};

FILE *file;
int main(void)
{

struct products others[7];
int i=0 , cnt;
cnt=Input_data(others);
cnt=caculation(others);
cnt=print(others);
return 0;
}

int caculation(struct products *others)
{
int i,cnt;
for(i=0; icnt; i++)
{
others[i].prices = others[i].volume * others[i].price;
if(others[i].volume50)
{
others[i].discount_price = others[i].prices * 0;
}
else if(others[i].volume100)
{
others[i].discount_price = others[i].prices * 0.05;
}
else
{
others[i].discount_price = others[i].prices * 0.1;
}
others[i].real_price = others[i].prices - others[i].discount_price;
}
file = fopen(out_data.txt,wt);
if(file==NULL)
{
printf(The file was not opened \n);
return 0;
}
return 0;
}

int print(struct products *others)
{
int i,cnt;

for(i=0; icnt; i++)
{
fprintf(file, %s \t , others[i].name);
fprintf(file, %d \t , others[i].price);
fprintf(file, %d \t , others[i].volume);
fprintf(file, %d \t , others[i].prices);
fprintf(file, %.lf \t , others[i].discount_price);
fprintf(file, %.lf \n , others[i].real_price);
}
return 0;

}int Input_data(struct products *others)
{
FILE *file;
int i=0,cnt;
file = fopen(in_data.txt , rt);
if(file==NULL)
{
printf(file open error!\n);
exit(1);
}
while(!feof(file))
{
fscanf(file,%s , others[i].name);
fscanf(file,%d , &others[i].price);
fscanf(file,%d , &others[i].volume);
i++;
}
cnt=i;
if(fclose(file)!=0)
{
printf(file close error!\n);
exit(1);
}
*(others+i);
others[i];
return cnt;
}

신청하기





COMMENT

댓글을 입력해주세요. 비속어와 욕설은 삼가해주세요.

번호 제 목 글쓴이 날짜
2700150 꼭좀 도와주세요ㅠㅠㅠ 호습다 2025-07-02
2700095 연산문제...질문... 오빤테앵겨 2025-07-01
2700070 while문 , 3의배수 출력하는 프로그램좀 짜주세욤. 횃불 2025-07-01
2700041 초보인데요 ㅎ 배열안에 배열을 집어넣을수 있나요?? 헛장사 2025-07-01
2700012 배열// (1) 전갈자리 2025-07-01
2699895 무한루프에 빠집니다.!! 해결좀부탁드려요 (10) 선아 2025-06-30
2699842 질문을 너무 많이 하네여.....죄송.... (2) 해님꽃 2025-06-29
2699816 오류 질문입니다.. (1) 해비치 2025-06-29
2699763 질문입니다 ! 꼭 좀 도와주세요ㅠㅠ (2) 미라 2025-06-28
2699555 c언어 다항식을 입력을 했는데 왜 출력이 안될까요? 피스케스 2025-06-27
2699528 C언어 포인터연산 질문입니다. (3) 안녕나야 2025-06-26
2699476 끌어올림;;달력 짜봤는데요 이 소스 줄일 수 있나요? - 스샷첨부 (2) 클라우드 2025-06-26
2699444 [좀 급함] system("explorer [주소] ") 문에 변수를 사용할 수 있나요? 알 2025-06-26
2699415 파일//read//와 배열 아란 2025-06-25
2699386 구조체 안에 일부분만 char 배열에 복사하려면 어떻게 해야하나요? (1) 미즈 2025-06-25
2699361 연결리스트 정렬하는 부분에 대해서 질문 드립니다 아이처럼 2025-06-25
2699304 [기초]아직 안주무시는분 계신가요..?포인터배열? 좀 도와주세요. 놀리기 2025-06-24
2699272 printf() 함수이용해서 프로그램 만들기 질문요! (5) 다가 2025-06-24
2699221 PUSH와 POP코드를 더 간단하게 어떻게 해야할까요? 파라미 2025-06-24
2699192 설치오류가 자꾸 나요 한번봐주세여~ (1) 소녀틳향기 2025-06-23
<<  이전  1 2 3 4 5 6 7 8 9 10  다음  >>

수다닷컴 | 여러분과 함께하는 수다토크 커뮤니티 수다닷컴에 오신것을 환영합니다.
사업자등록번호 : 117-07-92748 상호 : 진달래여행사 대표자 : 명현재 서울시 강서구 방화동 890번지 푸르지오 107동 306호
copyright 2011 게시글 삭제 및 기타 문의 : clairacademy@naver.com