|
||
|
GP Mailing List
ATXGPSIG List
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] formated Logger string problem solved
Hi GameProgrammer user,
it's me again...
I solved the problem with the formatted strings by myself.
For all who interrest in such code, here is the working one:
#include <stdarg.h>
void CLogger::Log(char *LogString ...) {
va_list ArgList;
va_start(ArgList, LogString);
vfprintf(m_LogFileStream, LogString, ArgList);
va_end(ArgList);
}
while ArgList is a pointer to the argument list, m_LogFileStream is
a member variable which holds the FILE handle.
This works perfect, tested with none or many arguments.
So...
One problem solved, but i have another one:
I'm working on a class to write and read from/to a config file. I
implemented also a method to write comments (c compliant, so with an
following //) to the file. Here is the code that won't function in
any fact:
void CConfigurationFile::SaveComment(char *Value) {
char *CommentString = "";
strcpy(CommentString, "// ");
strcat(CommentString, Value);
strcat(CommentString, "\n");
fputs(CommentString, m_ConfigFileStream);
}
while, m_ConfigFileStream is the FILE handle.
The misterious about that is, that it will compile without an error
but if the program is started and i want to write a comment into the
already open file it crashes and nothing happened.
If i debug this the debugger means, that there was access violation
in strcat.asm.
I'm not the perfect c coder, so i had now idea how to fix that,
above all there is no logical error (that's my and the compiler's
opinion ^_^) btw, like i said, i'm using VC++6.
'Till the next mail...
---
KingFish
gryphon entertainment - www.kingfish.myokay.net
---
"Truly, if there is true evil in this world,
it lies within the heart of mankind."
- Edward D. Morrison
=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once
To SUBSCRIBE or UNSUBSCRIBE please visit:
http://gameprogrammer.com/mailinglist.html
|
|