Basically what I'm doing is making a base program that I can build other programs off of, and I have a function (called input) that returns the characters collected from a user input. Right now, there's a 2 errors saying "return makes integer without a cast", and "function returns address of local variable". What I want it to be able to do is return a character array.
Here is the code:
#import <stdio.h>
void cls() {
system(cls);
}
char input() {
char X[0];
int Y = 0;
char Z;
while (1 == 1) {
Y = Y + 1; //increment step
Z = getch(); //get character input
if (Z == ';') {
break;
} //break if stop character is pushed
char Q[Y];
int a;
for (a = 0; a < Y; a = a + 1) {
Q[a] = X[a];
} //pass the items of X to the larger Q array
Q[Y] = Z; //add new value to Q at end of array
char X[Y];
int b;
for (b = 0; b < Y + 1; b = b + 1) {
X[a] = Q[a];
} //pass the items of Q back to a larger X
printf(X);
}
return X;
}
int main() {
while (1 == 1) {
//stuff will go here later
}
return 0;
}