Tiny calculator
In order to record balance sheet on android terminal
tiny calculator becomes to be needed
Please refer to source code about detail
#include <stdio.h>
#include <stdlib.h>
int main(){
char buf[80];
char operator;
char str1[80];
char str2[80];
int datum1;
int datum2;
int i,j;
while(1){
i=j=0;
scanf("%s",buf);
while(buf[i] != '+' && buf[i] !='-')
str1[j++]= buf[i++];
str1[j+1] = '\0';
operator = buf[++i];
j=0;
while(buf[i]!='\0')
str2[j++]=buf[i++];
str2[j+1]='\0';
datum1 = atoi(str1);
datum2 = atoi(str2);
if(operator=='+')
printf("%d\n",datum1+datum2);
else
printf("%d\n",datum1-datum2);
}
}
Fnews-brouse 1.9(20180406) -- by Mizuno, MWE <mwe@ccsf.jp>
GnuPG Key ID = ECC8A735
GnuPG Key fingerprint = 9BE6 B9E9 55A5 A499 CD51 946E 9BDC 7870 ECC8 A735