|
I haven't found any! I have created an incomplete header that contained code like this:
typedef basic_string<TCHAR> tstring;
|
|
|
|
|
George L. Jackson wrote: I have created an incomplete header
Could you send it my way?
If so just send it to the email address you find in the emailed reply notification you get with this message.
Thanks
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
I will need to look for it. I have not used it for some time since I only program on 32-bit platforms and only use Unicode. I think it might be at work.
|
|
|
|
|
Also, I just remembered a couple of problems I ran into using the header file.
The filename argument for file streams are always narrow, and support for multi-byte character strings is limited. However, I wrote the header file for vc++ version 6. I haven't used it with the new versions since I have been using MC++ or C++/CLI almost exclusively.
|
|
|
|
|
|
I decided to roll my own. It may not be perfect but I thought I would post here for posterity's sake.
#pragma once
namespace std
{
#if defined UNICODE || defined _UNICODE
typedef wstring tstring;
typedef wstringbuf tstringbuf;
typedef wstringstream tstringstream;
typedef wostringstream tostringstream;
typedef wistringstream tistringstream;
typedef wstreambuf tstreambuf;
typedef wistream tistream;
typedef wiostream tiostream;
typedef wostream tostream;
typedef wfilebuf tfilebuf;
typedef wfstream tfstream;
typedef wifstream tifstream;
typedef wofstream tofstream;
typedef wios tios;
# define tcerr wcerr
# define tcin wcin
# define tclog wclog
# define tcout wcout
#else // defined UNICODE || defined _UNICODE
typedef string tstring;
typedef stringbuf tstringbuf;
typedef stringstream tstringstream;
typedef ostringstream tostringstream;
typedef istringstream tistringstream;
typedef streambuf tstreambuf;
typedef istream tistream;
typedef iostream tiostream;
typedef ostream tostream;
typedef filebuf tfilebuf;
typedef fstream tfstream;
typedef ifstream tifstream;
typedef ofstream tofstream;
typedef ios tios;
# define tcerr cerr
# define tcin cin
# define tclog clog
# define tcout cout
#endif // defined UNICODE || defined _UNICODE
}
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
-- modified at 2:20 Sunday 12th February, 2006- 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
-- modified at 1:28 Sunday 12th February, 2006
|
|
|
|
|
How about:
extern tistream& tcin;
#endif
#ifdef _UNICODE
tistream& tcin = wcin;
#else
tistream& tcin = cin;
#endif That should be preferable to defines, as it will preserve the variable and typename, which may be helpful when debugging.
If you're not compiler sensitive (portability etc), you can always try
#ifdef _UNICODE
__declspec(selectany) tistream& tcin = wcin;
#else
__declspec(selectany) tistream& tcin = cin;
#endif __declspec(selectany) eliminates the need for a .cpp file, as it instructs the compiler to allocate space for the reference in one and only one compilation unit. Nice if you want to eliminate the need for lib files.
|
|
|
|
|
I have never tried the "__declspec(selectany)" solution. Thanks for the insight.
|
|
|
|
|
Just put something like this in you precompiled header ("StdAfx.h"):
#include <string>
#ifdef _UNICODE
typedef std::wstring tstring;
#else
typedef std::string tstring;
#endif // _UNICODE
Then use tstring like TCHAR and such.
Steve
|
|
|
|
|
I have used the basic_string<TCHAR> typefef myself in the past, but nowadays I _always_ compile for Unicode, and use std::wstring everywhere. I then link with the UnicoWS library so my apps work on Win9x. It hasn't given me any problems.
|
|
|
|
|
I am Using CArray as Two Dimensional Array Containing float type vlaues.Say for Example the inital size of the Array is [4][4] now i want to increase the size to [5][4]..And i want insert Row in between 2nd and 3rd rwos. Can CArray insert new row between 2nd and 3rd rows and will it adjust rest the data in the array to new size..?
Thanks Before
James
-- modified at 23:33 Saturday 11th February, 2006
|
|
|
|
|
Post a little code please.
How is the 2D array declared?
Is it realy setup as 2D array? Then yes.
Are you faking a 2D array? Then no, because you need to do the calculations?
Modifed:
Just read the previous post.
Hints:
Wheeler gave you a 2D array.
McFarlane gave you a fake 2D array.
Which are you using?
INTP
Every thing is relative...
-- modified at 11:24 Sunday 12th February, 2006
|
|
|
|
|
Hello everyone!
Alright, I have this struct:
struct Person<br />
{<br />
char FullName[50];<br />
int Age;<br />
};
I open a binary file with ios::out | ios::binary | ios::app , so it appends to the file, so there can be many of these structs in a file... The write function is fine, because it outputs alright if I use a single-reading function... Here's how I read it with the multiple-reading function:
int entries = getNumOfEntries(&dat_file);<br />
<br />
Person persons[entries];<br />
<br />
for (int x = 0; x < entries; x++)<br />
{<br />
dat_file.read((char*) &(persons[x]), sizeof(Person));<br />
}
It outputs some weird stuff... Anyone realize what I'm doing wrong? Thanks!
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|
|
An example of weird stuff would help.
You could try changing the conversion in the read statement to (unsigned char*).
Single stepping through the read loop should help.
The line "Person persons[entries];" is illegal and should not compile. I think you mean "Person* persons new Person[entries];".
Note: This does not affect you code, as written (povided you write records the same way), but unless you set packing for the structure, then the compiler will allign it to the next 4-byte boundry. So your structure size is realy 56 bytes not 54.
I assume that you have reopened the file with ios::in.
INTP
Every thing is relative...
|
|
|
|
|
Hmm... Well, I have changed things a little bit... I now write the char and the int alone, with no Person in between, but it won't work!
<br />
dat_file.write(person.FullName, sizeof(char)*NAME_SIZE);<br />
dat_file.write((char*) &person.Age, sizeof(int));<br />
<br />
dat_file.read(person.FullName, sizeof(char)*NAME_SIZE);<br />
dat_file.read((char*) &person.Age, sizeof(int));<br />
The file is now exactly 54 bytes...
Hmm... I tried cout ing dat_file.tellg() a few times between the read functions, and it said -1 on all of them... Maybe that's the problem? Thanks!
P.S: The file only contains 1 char and 1 int , no more.
P.S: I forgot to tell you that I get the size of the file with this:
long getFileSize(fstream * tempFile)<br />
{<br />
long begin, end;<br />
begin = tempFile->tellg();<br />
tempFile->seekg (0, ios::end);<br />
end = tempFile->tellg();<br />
return end-begin;<br />
}
It's repositioning the get pointer! I tried setting it to 0 after everything, but nope, didn't work... Still get the weird stuff:
Name: Vσ┬wP▼=
Age: 2009291924
P.S: Sorry for modifying that much, but I discovered something... Even if I change the name from "Leo" to "loahxoatlksrtjazme3h10ortlsahrzlirdatrengjklsafui5", I still get the exact same output!
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
-- modified at 13:06 Sunday 12th February, 2006
|
|
|
|
|
Your writing and reading where ok, as long as you read and wrote the same way. It would just mean that if some one else was going to read or write to the file, you would have to have documented the actual size of the record.
Whoops! getFileSize()
After calling end = tempFile->tellg(); , you need to call tempFile->seekg(0, ios::beg); . If you do not, then you will be trying to read from the end of the file. That is tellg will return -1.
You have the right idea for a general purpose function for getting the size, but I would probably do something like this:
long getFileSize(fstream * tempFile)
{
long begin, end;
begin = tempFile->tellg();
tempFile->seekg (0, ios::end);
end = tempFile->tellg();
tempFile->seekg (begin);
return end;
}
INTP
Every thing is relative...
|
|
|
|
|
|
Hi,
As in C++ , double matrix[10][10]; two dimensional array...How can we use CArray as a two dimensional..? IF we can how Can we add eleents in to this two array?.
Thanks before..
|
|
|
|
|
typedef CArray <int, int> CIntArray;
typedef CArray <CIntArray, CIntArray&> CMultiIntArray;
void TraceDynamicArray(const unsigned int rows, const unsigned int columns)
{
CMultiIntArray aTest;
aTest.SetSize( rows );
for (int row = 0; row < aTest.GetSize(); row++)
{
aTest[row].SetSize( columns );
for (int column = 0; column < aTest[row].GetSize(); column++)
{
aTest [row] [column] = 10 * row + column;
afxDump << aTest [row] [column] << "\t";
}
afxDump << "\n";
}
}
Kevin
|
|
|
|
|
I am new to MFC...As we do in C++
double matrix[10][5];
double somedoubleValue=10.005;
for(int i=0;i<10;i++)
{
for(int j=0;i<5;j++)
{
matrix[i][j]=i*j*somedoubleValue;
}
In the same manner instead i want to use CArray..bec..the Array matrix size can increase in future and i want insert in between..so i want to CArray as two dimesional array......Can we more Clear..I have read above posted message..but i don`t how to use it....so pls can be more clear.
Thank q
James
|
|
|
|
|
Try this:
CArray<CArray<int>> array;
array.SetSize(number_of_rows);
for (int row = 0; row < number_of_rows; row++) {
array[row].SetSize(number_of_columns);
}
for (int row = 0; row < array.GetSize(); row++) {
for (int col = 0; col < array[row].GetSize(); col++) {
array[row][col] = 0;
}
} This creates a two-dimensional array that is dimensioned [number_of_rows,number_of_columns] . Note that each row can be sized differently if necessary.
Software Zen: delete this;
|
|
|
|
|
I'm trying to create an AddIn for VC++ 7.1, and I'm having problems inserting a submenu into the Tools menu.
I'm also not sure how to undo the installation, so that when you look at AddIn manager, the AddIn is no longer listed.
How do I add a submenu, and how do I remove the AddIn to VC++ 7.1?
I have the following source code:
http://code.axter.com/Connect.cpp
And the current code is in the CConnect::OnConnection method.
I'm only interested in C++ methods, and not any VB code.
Thank you
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
|
|
|
|
|
Hello everyone!
I'm doing a program to learn how to use binary files...
I have a struct that has one member of type std::string and one int. I want to write that struct to a binary file, but just the int gets written!
fstream dat_file(file.c_str(), ios::out | ios::binary);<br />
<br />
Person person;<br />
<br />
person.FullName = fullName;
person.Age = atoi(strAge.c_str());<br />
<br />
dat_file.write((char*) &person, sizeof(Person));<br />
<br />
dat_file.close();
Why won't it write the name to the file? Thanks!
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|
|
|