On 18/05/2013 at 00:33, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14
Platform: Windows ;
Language(s) : C++ ;
---------
Hi Folks,
I'm having a bit of a strange issue printing out the first few characters of a text file I'm trying to read. Instead of printing out each character (as what I thought the for loop below would do..) it's printing out the character along with the file's path! Code below:
AutoAlloc<BaseFile> BFile;
Filename FName;
FName = Filename("D:\TextFile.txt");
if(!BFile->Open(FName, FILEOPENREAD))
{
GePrint("File not found!");
}
CHAR *Char;
String str;
for(int I = 1; I <= 2;) // example trying to get first two characters
{
BFile->ReadChar(Char);
str += CharToString(Char); // little function to turn char to a string..
GePrint(str); // this results in the print example below...
I++;
}
Prints: "R:\TextFile.txt" where the drive letter is replaced by the Char letter (in this case an "R").
I haven't got anything else in the code that could be affecting this I wouldn't have thought. There's a LONG to get the length/number of characters in the file and print the result. But other than that, that's about it! The character prints are correct, that is the ReadChar is getting the right character in the file, but what's with the file extension etc being printed as well!? Is this a bug or something I'm doing incorrectly?
WP.