sorry, i couldnt think of a better title. What im trying to do is to make a CAS system, and i need to define certain things, such as a "term". a term consists of a coefficient and symbols, such as xyz. its a bit more complicated but you get the picture. Ive got something working on python, and now im porting it to c, i dont really have much experience with c which is why i need a bit of help.
Firstly, how do you pass strings to structs. For example
Code:
typedef struct test
{
char str[30];
} test;
void main()
{
test test;
test.str[30] = "test";
printf(test.str);
}
outputs a whole bunch of random characters.
also, my struct for a term will look something like this.
Code:
typedef struct Term
{
coefficient coefficients[];
symbol symbols[];
bracket brackets[];
} Term;
The problem is is i don't know how many coefficients, symbols, or brackets each term is going to have. This is a problem because I want to put this onto my calculator, which has about 100kb of free ram if im lucky, so having an array of 26 symbols just to make sure i can fit them all will result in huge wastage. is there a method to get around this. Thanks.