[C] #define 매크로를 활용한 사칙연산 계산기
#include #pragma warning(disable:4996) #define ADD(x,cal,y) printf("%d %c %d = %d\n",(x),(cal),(y) ,(x+y)) #define MUL(x,y) ((x)*(y)) #define SUB(x,y) ((x)-(y)) #define DIV(x,y) ((x)/(y)) #define input_expression(x,cal,y) scanf("%d %c %d",&(x),&(cal),&(y)) int main(void) { int sel = 0; int num1, num2; char cal; while(1) { printf("수식입력(종료:ctrl+z): "); if (input_expression(num1, cal, num2) < 0) { ..
2023. 10. 14.
[C]텍스트 파일 2개 열고 단어 비교 후 등록 안된 단어 다른 텍스트 파일에 저장
#if 1 /* txt파일a,b,c 3개열고a에단어최대10개, 단어길이는20자로제한, b에는검출대상단어를입력하고제한없음, c에는 a에있는데b에등록안된단어를저장함. */ #include #include #pragma warning(disable:4996) int check_word(char aword[10][20], char bword[20], int cnt) { int i=0; for (i = 0; i < cnt i++) { if (!(strncmp(aword[i], bword, strlen(aword[i]) - 1))) { printf("\n동일단어검출!\n"); return 0; } } return 1; } int main(void) { FILE* afp, *bfp, *cfp; char aword[1..
2023. 10. 14.
[C]실수 값 오름차순 정렬
혼자 공부하는 C언어 책 P289 예제 변형 솔루션 입니다. scanf로 되어 있는것을 fgets(input,100,stdin)의 형태로 입력 받아서 처리해보겠습니다. #include #include #include void spacecheck(char *input, int *point); void swap(double *pa,double *pb); void line_up(double *maxp,double *midp,double *minp); int main(void) { char input[70]; int point=0; char maxc[20],midc[20],minc[20]; double max,mid,min; int temp; printf("실수값 3개 입력 "); fgets(input,70,s..
2023. 10. 14.