0

I need help in making the character array str[] in mips and also reading out that array. I have to functions where I ask the user to enter a base between 2 and 36 and then prompt them to enter a number in that base and that number is converted to base 10(decimal).

int convert2dec(char *str, int base) 
{
  int j, val;
  val = 0;
  j = 0;
  while (str[j] > 13) {
    if (str[j] > 57) 
      val = val * base + str[j]-87;
    else
      val = val * base + str[j] - 48;
    j++;
  }
  return val;
}

int main(int argc, char *argv[])
    {
      int X;
      char str[256];
      printf("Please the base (between 2 and 36 in decimal): ");
      scanf("%d", &X);
      printf("Please a number base %d: ", X);
      scanf("%s", str);
      printf("The decimal value is %d\n", convert2dec(str,X));
      return 0;
    }  
Saveen
  • 4,120
  • 14
  • 38
  • 41
  • What's the actual problem? If you're getting errors or incorrect output, please update your question to specify exactly what you need help with. – Stephen Newell Mar 20 '18 at 03:31
  • since your question is about MIPS you should include MIPS code examples. We are not compilers ;) Creating a char array is the same as creating any other array in MIPS. If you [know how to do that](https://stackoverflow.com/questions/27074044/mips-assembly-arrays) you are 90% there. – avigil Mar 20 '18 at 03:32

1 Answers1

0

I can make a regular array, but im just confused with char arrays in mips. Im not asking to answer any problems for me. Im just cunfused with char arrays in mips and reading them out.