Hi guys can someone assist me, I'm quite new in C. I'm trying to write a maths expression of sort where the letters A,B,C,D,E are corresponding elements of an array row. I need to extract it as a string eg If I input y=A*B-C+D*E I wish the ouput string to be
5*3-2+3*4 for the first row. I've trying to do this but it's giving me a tough time.
Code:
#include<stdio.h>
#include<stdlib.h>
#define MAXCOLS 80
main()
{
int num_operand =5;
int num_operatr = 4;
int strglen=num_operand+num_operatr;
char operand;
int i, j;
char string[MAXCOLS];
char a[2][5]={{5,3,2,3,4},{2,5,4,6,8}};
printf("Enter a command of the sort A+B*C_D*E:\n");

for(j=0; j<strglen; j++){
operand=getchar();
if(operand >= 'A' && operand <='Z')
string[j]=a[0][(int)operand-(int)('A')];
else{
string[j]=(char)operand;}}

  printf("Expression\n");
  for(i=0; i<strglen; ++i){
  printf("%d \n", string[i]);
  getchar();}
 }