수다닷컴

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

라이브러리 도와주세요.

낶아

2023.04.01


질문 제목 : 정적라이브러리질문 요약 :주요기능을 정적라이브리로 생성해서
메인에서 사용하는건데.. 읽히지가 않습니다.질문 내용 :
mylib.c
#includestdio.h
#includestdlib.h
void input_score(float *score, int n)
{int c;
for(c=0;cn;c++)
scanf(%f,&score[c]);

}
void input_score_file(file* infile,float* score,int n)//파일을 읽어 score[c]에 저장
{ int c;
for(c=0; cn; c++)
fprintf(infile,%f,&score[c]);
}
void print_score(float* score,int n)//점수 출력
{int c;
for(c=0;cn;c++)
printf(점수:%f\n,score[c]);
}
float max_score(float* score,int n)//최대점수
{
float max;
if(n==1){
return score[0];
}
max=max_score(score,n-1);
if(maxscore[n-1])
{
return score[n-1];
}
return max;

}
float min_score(float* score,int n)//최소점수
{
float min;
if(n==1){
return score[0];
}
min=min_score(score,n-1);
if(minscore[n-1])
{
return score[n-1];
}
return min;
}
float sum_score(float* score,int n)//총합점수
{
float sum=0;
if(n0){
sum=score[n-1]+sum_score(score,n-1);
}
return sum;
}
void print_result(float max,float min,float sum,float mean)//결과값 출력
{
printf(최댓값 : %f \n최소값 : %f\n합친값 : %f\n평균값 : %f,max,min,sum,mean);
}
void save_result_file(file* outfile,float max,float min,float sum,float mean)//reusult.txt에 저장값
{
fprintf(outfile, 최고점수: %f, max);
fprintf(outfile, 최소점수: %f, min);
fprintf(outfile, 총합점수: %f, sum);
fprintf(outfile, 평균점수: %f, mean);
}

mylib.h
#include stdio.h
#include stdlib.h
void input_score(float* score,int n);
void input_score_file(file* infile,float* score,int n);
void print_score(float* score,int n);
float max_score(float* score,int n);
float min_score(float* score,int n);
float sum_score(float* score,int n);
void print_result(float max,float min,float sum,float mean);
void save_result_file(file* outfile,float max,float min,float sum,float mean);

main.c
#include stdio.h
#include stdlib.h
#include mylib.h

int main(void){

int n=0;
float* score;
float scoren;
float max=0,min=0,sum=0,mean=0;
file *infile,*outfile;

infile=(file*)fopen(score.txt,wt);//socre.txt 오픈
if(infile==null)
{
printf(에러: 입력 파일을 열 수 없읍!!\n\n);
return;
}
printf(학생수를 입력하세요:);
scanf(%d,&n);

score = (float *)malloc(n*sizeof(float));
if (score == null)
{
printf(에러: 동적 메모리 할당 실패!!!\n\n);
return;
}
input_score(score,n);
input_score_file(infile,score,n);//파일을 읽어 score[c]에 저장
print_score(score,n);//점수 출력
fclose(infile);//score.txt 닫음
max=max_score(score,n);//최고점수
min=min_score(score,n);//최저점수
sum=sum_score(score,n);//총합계
mean=sum/n;//평균

free(score);

print_result(max,min,sum,mean);//결과값 출력
outfile=(filile=(file*)fopen(result.txt,w);//result.txt 생성
if(outfile==null)
{
printf(에러: 입력 파일을 열 수 없읍!!\n\n);
return;
}
save_result_file(outfile, max, min, sum, mean);//result.txt에 저장될 값
fclose(outfile);//result.txt 닫음
}#include mylib.h에서 파일 소스를 읽을수 없다고 뜸니다.

신청하기





COMMENT

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

번호 제 목 글쓴이 날짜
2700562 함수포인터에서요 (7) 소심한여자 2025-07-06
2700530 전처리문 질문입니다. (1) 아놀드 2025-07-05
2700510 c언어를 어케하면 잘할수 있을까요.. 연연두 2025-07-05
2700484 두 개가 차이가 뭔지 알려주세요...(소수 찾는 프로그램) (2) 날위해 2025-07-05
2700426 인터넷 창 띄우는 질문이요 (1) 정훈 2025-07-04
2700400 원넓이를 계산이요 ㅜㅜ 천칭자리 2025-07-04
2700368 if에 관해서 질문이요... Orange 2025-07-04
2700339 이거 결과값이 왜이런건지.. (4) 그댸와나 2025-07-04
2700313 파일 읽어서 저장하는데 빈파일일 경우 문재가 발생하네요.. (2) 크나 2025-07-03
2700287 구조체 동적할당 연습을 하는데 오류가 뜹니다...(해결) (3) 아련나래 2025-07-03
2700264 문자와 숫자 동시에 입력??? 글고운 2025-07-03
2700236 txt파일로만 쓰고 읽게 하려면 어떻게 해야 하나요..?? (8) 미국녀 2025-07-03
2700211 전위 연산자 (2) 어른처럼 2025-07-02
2700183 C에서 파일이름을 받고, 그 파일의 사이즈를 출력해줘야하는데 내용이 출력이 안되네요 ;ㅅ; 피스케스 2025-07-02
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
<<  이전  1 2 3 4 5 6 7 8 9 10  다음  >>

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