here is the code:
that's the header file, here is main:Code:#include <windows.h> #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <fstream.h> #include <iostream.h> #include <string.h> int keypress=0; char message[50]; int space1gone=0; int space2gone=0; void frame (int xmin,int ymin,int xmax,int ymax); void gotoxy(int,int); void getmove(char message[], int space1gone, int space2gone); char determinemessage(char message[], int keypress); void frame (int xmin, int ymin, int xmax, int ymax) { int count; gotoxy(xmin,ymin); putchar(218); gotoxy(xmax,ymin); putchar(191); gotoxy(xmin,ymax); putchar(192); gotoxy(xmax,ymax); putchar(217); gotoxy(xmin+1,ymin); for(count=xmin; count<xmax-1; count++) putchar(196); gotoxy(xmin+1,ymax); for(count=xmin; count<xmax-1; count++) putchar(196); for(count=ymin+1; count<=ymax-1; count++) { gotoxy(xmin,count); putchar(179); } for(count=ymin+1; count<=ymax-1; count++) { gotoxy(xmax,count); putchar(179); } } void gotoxy(int x, int y) { HANDLE hConsoleOutput; COORD dwCursorPosition; dwCursorPosition.X = x; dwCursorPosition.Y = y; hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleCursorPosition(hConsoleOutput,dwCursorPosition); } void getmove(char message[], int space1gone, int space2gone) { char tempmessage[50]; if(space2gone==0) //checks if first spot is open { if(space1gone==0) //checks if second spot is open { gotoxy(1,22); cout<<message; space1gone=1; } else if(space1gone==1) //first spot is used, second is open { gotoxy(1,23); cout<<message; } } else if(space2gone==1) //second spot is used { strcpy(tempmessage, message); gotoxy(1,22); cout<<tempmessage; gotoxy(1,23); cout<<message; } } char determinemessage(char message[], int keypress) { if(keypress==72) strcpy(message, "You moved up"); if(keypress==75) strcpy(message, "You moved left"); if(keypress==80) strcpy(message, "You moved down"); if(keypress==77) strcpy(message, "You moved right"); return message; }
i use msvc++. i think it is evident that i am trying to return the array of chars called message. how would i declare a function that returns an array of chars, not just a char?Code:#include <iostream.h> #include <windows.h> #include <conio.h> #include <fstream.h> #include "functions.h" int main() { frame(0,0,55,20); //Biggest box frame(56,0,79,24); //Right-side box frame(0,21,55,24); //Message Box for(;;) { if(kbhit()) { keypress=_getch(); message=determinemessage(message, keypress); getmove(message, space1gone, space2gone); } } return 0; }
i tried 'determinemessage[](....etc)'



LinkBack URL
About LinkBacks


