Quantcast
Channel: Forum Pasja Informatyki - Najnowsze pytania bez odpowiedzi
Viewing all articles
Browse latest Browse all 22017

Kalkulator w C

$
0
0

Hej, mam do napisania kalkulator w C. Mam problem, gdyż nie wiem w jaki sposób wczytać liczby oraz znaki artmetyczne ( jak użyć do tego funkcji "int isValidExpression(const char *str)" ?)  Mam utworzone funkcje, brakuje mi jednej, która będzie wykonywała operacje dodawnia, dzielenia itp. jednakże nie wiem jak ją napisać, aby korzystała ona z funkcji które są już powyżej, proszę o pomoc. 

#include<stdio.h>
#include<math.h>
#include "EvalExpression.h"

static float f1,f2;
static char op;
int isValidExpression(const char *str)
{
    int res;
    char ops[10];
    res=sscanf(str,"%f%s%f",&f1,&op,&f2);
    op=ops[0];
    return(res==3);
}
int getOperator()
{
    return(op);
}
float getFstOperand()
{
    return(f1);
}
float getSecOperand()
{
    return(f2);
}

 


Viewing all articles
Browse latest Browse all 22017

Trending Articles