I am writing a program for my TI 84+ CE in C using CEdev. In a function for my program, I define an int as a counter, but the compiler says "Syntax error" on the line where it is defined. Here is the code (with line numbers), and the compiler output:
42 int * factor2(int num) {
43
44 int half = floor(num / 2); // Ensures a whole number <= num.
45 int * str = (int*)malloc((half+1)*sizeof(int)); // 1 will be a part of every solution.
46 int i, j;
47 str[0] = 1;
48 int hello; //this is where the error is
49 hello = 1;
50 num % 2 == 0 ? (i = 2, j = 1) : (i = 3, j = 2);
51 for (i; i <= half; i += j) {
52 num % i == 0 ? str[hello++] = i : false;
53 }
54
55 str[hello] = num; // Always include the original number.
56 return str;
57 }
C CE SDK Version 7.4
Z:\Users\jack\Downloads\CEdev\TIProjects\NomialFactorTI\src\main.c
Z:\USERS\JACK\DOWNLOADS\CEDEV\TIPROJECTS\NOMIALFACTORTI\SRC\NOMIAL.C (48,8) : ERROR (100) Syntax error
Z:\USERS\JACK\DOWNLOADS\CEDEV\TIPROJECTS\NOMIALFACTORTI\SRC\NOMIAL.C (48,15) : ERROR (128) Identifier "hello" not defined within current scope
Z:\USERS\JACK\DOWNLOADS\CEDEV\TIPROJECTS\NOMIALFACTORTI\SRC\NOMIAL.C (51,8) : WARNING (222) Statement has no effect
make: *** [obj/main.obj] Error 255
Command /usr/bin/make failed with exit code 2
I'm not sure if this is the right place to post this, but C is closer to assembly than TI-BASIC so I posted here. I'm compiling on a Mac, if that's important.