|
is the function called with a valid file path as a parameter ??
what happens if changing fname from const wchar_t* to const char* ?
where is defined inFile ? is it well initialized ?
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20]
|
|
|
|
|
Hi,
Sorry, here is the definition for the class I'm using:
#include <stdio.h>
#include <fstream>
#include <vector>
#include <ios>
class fileOperator {
protected:
<
std::ifstream inFile;
std::ofstream outFile;
public:
fileOperator() {};
void openInputFile(const wchar_t *fname);
void openOutputFile(const wchar_t *fname) {};
void readMatrix(int numberOfColumns, double **matrix);
};
Using const char* was my first thought too, but my compiler doesn't seem to like it. It claims ifstream::open only accepts wchar_t* as its argument. Here's the compiler error I get:
.\fileTest.cpp(8) : error C2664: 'fileOperator::openInputFile' : cannot convert parameter 1 from 'char *' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
There might be some blindingly obvious thing I'm missing here as I'm fairly new to C++
Roger
|
|
|
|
|
you have to either wass it a char* string and to change the function prototype !!!
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20]
|
|
|
|
|
Sorry about that, with the function prototype changed to char*, the code compiles of course, but I still can't open the file...
Roger
|
|
|
|
|
"wchar_t *fname"?
You might considder "char * fname"?
Or a UNICODE build?
|
|
|
|
|
Does the path to the file look like this ?
const char *path = "C:\Test\TestFile.txt";
If that's true, then you need to escape the \ character by addding another \. Like
const char *path = "C:\\Test\\TestFile.txt";
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi,
Sorry, I'm not using the full path. The file I'm trying to read is in the same directory as the program itself. I tried using full path with the double \\, but to no use. The file still won't open.
Roger
|
|
|
|
|
I need to get my floating points calculation to run faster, the floating point numbers stored in instances of some class in vector<class> array I just need to multiply them and add result:
class{
float val1;
float val2;
};
for(i=0; i<size; i++)
="" res="" +="class[i]-">val1 * class[i]->val2;
will it be faster to store floating numbers from vector massive to plain floating array
float *ar1, *ar2;
for(i=0; i<size; i++)
="" ar1[i]="class[i]-">val1;
ar2[i] = class[i]->val2;
and then perform mmx calculations or memory moving ops will take also some time so there will be no significant speed increase? Or will it be faster to use compound intrinsics to load floating numbers to float[4] and then perform multiplication?
If some one encountered similar problem?
9ine
|
|
|
|
|
9ine wrote: perform mmx calculations
MMX instructions are all integer-based, so they can't help you at all with floating point calcs.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
I know about mmx, by this word I mean all multemedia extensions, it is SSE with floating points which I wonder about for my application if you need me to be more exact.
I can do it my self easely but dont want to waste time if some one done it before an got speed improvement, which I mean:
timemmx = [mem move from classes in vector<> array] + [SSE ops]
timefloat = [standart floating multiplications]
timemmx << timefloat! ??
Otherwise I will need to make much bigger changes in my code to get floating values from my vector<class> to align them in memory, which I'm reluctant.
9ine
|
|
|
|
|
i'm not sure anyone could say for sure without actually trying.
but, items in a vector are stored contiguously in memory, so you can treat them as a plain C++ array. (this is part of the 2003 C++ standard, IIRC - and all implementations store data that way regardless). so, you should be able to load the SSE registers directly from the contents of your vector.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
actually not the floating points are stored in vector but class instances with floating numbers
class CTest
{
public:
CTest();
~CTest();
float val1;
float val2;
}
and we get this vector<CTest *> array and we need to
for(i=0; i<array.size(); i++)
res += array[i]->val1 * array[i]->val2;
if we can try it keeping in mind that data in vector is stored lineary hence val1 and val2 stored with the same stride in memory?
9ine
-- modified at 9:42 Wednesday 7th December, 2005
|
|
|
|
|
16:00 IST
Good Afternoon to all of you,
My problem is based on changing the mouse pointer at the button click .
Like in ms-paint on clicking the the line button the mouse icon gets changed.
I would be highly obliged for the early response
Thanks and regards
|
|
|
|
|
pankajgarg11 wrote: Like in ms-paint on clicking the the line button the mouse icon gets changed.
Is SetCursor Api is of any help?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I am using VC 6.0. I am writing an MFC application where I use strings with the _T("") macro.(Character set neutral). Is there any way to convert from a LPTSTR to a float value. I noticed that the function _ttof does not exist in VC 6.0. Does anybody know how this conversion can be done.
Thx.
|
|
|
|
|
Hi
Use _tstof()
Bye,
Cool Ju
Dream Ur Destiny
|
|
|
|
|
_tstof() doesn't work.
C:\Projects\PCnt\XLConvDlg.cpp(835) : error C2065: '_tstof' : undeclared identifier
Thx
|
|
|
|
|
Hi,
Add math.h and stdlib.h
Bye,
Cool Ju
Dream Ur Destiny
|
|
|
|
|
Doesn't work. Same error.
|
|
|
|
|
|
Yes, but I want to use a character neutral set function.
Thx
|
|
|
|
|
paper67 wrote: Is there any way to convert from a LPTSTR to a float value.
what about _tcstod function
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
-- modified at 6:54 Tuesday 6th December, 2005
|
|
|
|
|
That's the one I need.
Thx a lot.
|
|
|
|
|
paper67 wrote: Thx a lot.
My Pleasure
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
How about the old standby, sscanf ? There is also a wide-character version, swscanf . If you've eliminated the whitespace around the string-represented floating-point value, then the following will work:
float fValue;
int nResult = sscanf((LPCTSTR)sData, "%f", &fValue);
if( nResult != 1 )
{
}
Bob Ciora
|
|
|
|