Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

日付を表示


#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>


double dentaku(void)
{
	int ret;
    char a;
    double b, c, ans;

    printf("+,-,*,/を入力してください\n");
    ret = scanf("%c",&a);
    printf("計算してください\n");
        
    switch (a){
        case '+':
			scanf("%lf",&b);
            scanf("%lf",&c);
            ans = b + c;
        break;
        case '-':               
            scanf("%lf",&b);
            scanf("%lf",&c);
        	ans = b - c;
    	break;

	    case '*':
	        scanf("%lf",&b);
	        scanf("%lf",&c);
	    	ans = b * c;
    	break;

	    case '/':
	    	scanf("%lf",&b);
	    	scanf("%lf",&c);
	    	ans = b / c;
    	break;
    	default:
    	    printf("");
    }
    return ans;
}

int main(void)
{
	int b, c,var1;
	double ans;
	FILE *fp;
	//char array[60] ;
	char ret;
	fp = fopen("log.txt", "a+" );
	//ret = fputs(array,fp);
	 time_t timer;
    struct tm *local;
    timer = time(NULL);

    local = localtime(&timer);

	var1 = dentaku();
	fprintf(fp, "%d/ %d/%d %d:%d:%d %d\n",local->tm_year + 1900,local->tm_mon + 1,local->tm_mday,local->tm_hour,local->tm_min,local->tm_sec,var1);
	fclose(fp);
	return 0;
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.