Omnimaga
Calculator Community => TI Calculators => Calculator C => Topic started by: apcalc on May 17, 2010, 08:40:19 pm
-
Hi. I am having trouble writing a program in C for the TI-89. I am very new to the language and I still have a lot to learn.
In TI-Basic, I have programs that can take a list, ex: {1,4,3,1,7,9}, and will retrive a certain element from the list. For example, if I called for element number 2, the function would return 4.
Is there any way I can get the same feature in C. Would I use "lists" like in TI-Basic, or is there a different method. Also, I would have the lists pre-entered in the program. The program would not have to add data to the lists.
-
Lets say I want a list of integers, length 6.
I'd declare it like so:
int list[6] = {1, 4, 4, 1, 7, 9}
and I'd access the 2nd element with:
list[1]
since arrays in C are indexed from 0.
-
I have another problem with lists in C. How to I add strings to a list? For example, I want the list
testlist[4]={"Test","List","Hello","World"};
How would I create this list. I tried declaring it as a character:
char testlist[4]={"Test","List","Hello","World"};
but this did not work. What am I doing wrong? Thanks again for your help! :)
-
char* testlist[4] is the declaration you need, I believe.