|
3 registered members (TipmyPip, clint000, Grant),
6,810
guests, and 4
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Console Output?
[Re: Germanunkol]
#345282
10/24/10 18:33
10/24/10 18:33
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
I guess I'll have to make input work as well somehow, that'll be harder... Not really, you can use stdin to fetch input from the user. A way to make it easier than just dumb listening to the file stream would be something like fscanf() that does this automatically for you.
Last edited by JustSid; 10/24/10 18:44. Reason: Forgot an f... shame on me
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Console Output?
[Re: Germanunkol]
#345299
10/24/10 21:44
10/24/10 21:44
|
Joined: Sep 2003
Posts: 9,859
FBL
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 9,859
|
Yes, guess why I couldn't get it to work?  STRINGS seem to mess up, but that makes sense I guess, since they're acknex-structs... Oh well. It works now. I guess I'll have to make input work as well somehow, that'll be harder... STRING* strTest = str_create("Hello Acknex"); char* cTest = strTest->chars; //pass to console This should work.
|
|
|
Re: Console Output?
[Re: Germanunkol]
#345414
10/25/10 23:55
10/25/10 23:55
|
Joined: Oct 2004
Posts: 900 Lgh
rojart
User
|
User
Joined: Oct 2004
Posts: 900
Lgh
|
Try this example, already converted from here.
#include <acknex.h>
#include <windows.h>
#include <stdio.h>
#define BUFSIZE 4096
typedef char CHAR;
CHAR chBuf[BUFSIZE];
DWORD dwRead, dwWritten;
HANDLE hStdin, hStdout;
BOOL bSuccess;
void logToConsole(STRING* logStr) {
WriteFile(hStdout, logStr, str_len(logStr), &dwWritten, NULL);
WriteFile(hStdout, "\n", 1, &dwWritten, NULL);
}
void main() {
video_screen = 0;
AllocConsole();
SetConsoleTitle("CSiS Dedicated Server");
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
hStdin = GetStdHandle(STD_INPUT_HANDLE);
logToConsole("CSiS Dedicated Server");
if ( (hStdout == INVALID_HANDLE_VALUE) || (hStdin == INVALID_HANDLE_VALUE) ) ExitProcess(1);
// Send something to this process's stdout using printf.
//printf("\n ** This is a message from the child process. ** \n");
// This simple algorithm uses the existence of the pipes to control execution.
// It relies on the pipe buffers to ensure that no data is lost.
// Larger applications would use more advanced process control.
for (;;) {
// Read from standard input and stop on error or no data.
bSuccess = ReadFile(hStdin, chBuf, BUFSIZE, &dwRead, NULL);
if (! bSuccess || dwRead == 0) break;
// Write to standard output and stop on error.
bSuccess = WriteFile(hStdout, chBuf, dwRead, &dwWritten, NULL);
if (! bSuccess) break;
}
return 0;
}
|
|
|
|