|
Thaank you Joaquin,like always
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
If you have no trouble allocating the buffer, you should be able to just type cast the ULONGLONG to a size_t for your count parameter.
Just keep in mind that files can be a lot larger than your address space allows for, in which case you might want to look into memory mapped files.
|
|
|
|
|
hmmmm,thank you
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
A char is one BYTE , so when GetLength() returns the file size, it is giving you the number of BYTE s, thus the number of char s
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
wowww,that's it.Thank you.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
It does in VS.NET's version of MFC. But in six it's a DWORD.
This kind of thing caused me about 200 warnings when i upgraded.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Hello to everyone.My name is Nektarios and I am from Greece.I am new to programming so I have a lot off questions.I am studing Electronics and I have to do a project for my degree.This is to programm an ISDN switching centre.
I am writng this message in order to learn how to split a string to substrings.I will explain what I mean.Let's suppose that I have a string for example : Let us get out of here.I want to split this string into variables and every one of this have a word of this string.
So var1->Let , var2->us , var3->get var4->out , var5->of , var6->here.
Thank you in advance.Nektarios
The truth is out there
|
|
|
|
|
I don't think you use MFC,but if the answer is yes you can check for CString class.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Yes I am using MFC.As I have written before I am now to programming and I now very few things.For this reason I wrote this message.Can you help me?I now that I must search CString.
Thank You ,Nektarios
The truth is out there.
|
|
|
|
|
The thing I can guess now is:
Use FindOneOf() to find spaces,then use Left() to extract those number.
Have you got it or you need more?
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
You can also use Find() instead of FindOneOf()
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
There are a lof of types called "strings". Mazdak anwered as for MFC CString s.
Most probably, you're using char * s. In this case, the usual (though not especially good) way to go is using function strtok .
If you're using std::string s, use a tokenizer like Boost tokenizer. Having into account you're new to programming, you might need some help from someone with more experience to install and begin to use this library.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
If you are using a standard char array, you can use a function called strtok . This function will allow you to step through a string and find all of the tokens, or substrings. Here is a short example:
#include "stdafx.h"
#include "stdlib.h"
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
char str[] = "Let us get out of here, NOW!";
char *vars[10];
int index = 0;
vars[index] = strtok(str, " ,");
while (vars[index] &&
index < 10 )
{
index++;
vars[index] = strtok(NULL, " ,");
}
int token;
for (token = 0; token < index; token++)
{
cout << vars[token] << endl;
}
return 0;
}
|
|
|
|
|
As it seems your code is good but I don't understand the meaning of some commnds
What this command do?
vars[index] = strtok(str, " ,");
What this examine?
while (vars[index] && index < 10 /*There is only space for ten strings.*/)
Please explain.
|
|
|
|
|
Nektarios Sourligas wrote:
vars[index] = strtok(str, " ,");
Earlier I created an array of 10, char* pointers. This is the pragmatic way to hold the variables that you originally mentione din your first question,
var1, var2, var3 ...
Except for in this case, you access the variables like this, using a zero indexed array:
vars[0], vars[1], vars[2] ...
strtok returns the pointer to the next token in your string. Therefore I assign the result of strtok to the current variable. I keep track of the current variable with the index value. index starts at 0. If you wanted to write it out with the 6 or 7 variables that you had it would look like this:
var1 = strtok(str, " ,");
var2 = strtok(NULL, " ,");
var3 = strtok(NULL, " ,");
... and so on.
Nektarios Sourligas wrote:
while (vars[index] && index < 10 /*There is only space for ten strings.*/)
1) vars[index]:
I should have been more explicit with this, another way to write this is (NULL != vars[index] . Basically I am testing the variable for NULL. If strtok reaches the end of the string, and there are no more tokens, then it will return NULL, and we know that we are done parsing the string.
2) index < 10
This is just to be safe, in case you wanted to change the string that I provided. The string that I provided had 7 tokens in it. If you changed the string to something with more than 10 tokens in it, and that test was not there, then most likely an error would occur. I am simply making sure that no more than 10 tokens are assigned from strtok
One more thing that I forgot to mention about strtok, is that it modifies the string that you are parsing, so if you want to keep the original string intact, you will want to make a copy of that string, and use the temporary version of it, like so:
char originalStr = "This is the original string.";
char *tempStr;
int iLen = strlen(originalStr);
tempStr = new char[iLen+1];
if (NULL == tempStr)
{
}
char* var1 = strtok(tempStr, " ");
...
delete[] tempStr;
Good Luck
|
|
|
|
|
You said you're using MFC, so use AfxExtractSubString() to split the full string on spaces.
--Mike--
"Jobs that don't allow you to visit the Lounge 25 times a day at the minimum are not worth having anyway."
-- Nish, 3/28/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
How do I list the classes / methods / properties defined in a com component programatically?
(something similar to object browser / intellisense feature found in VB)
regards and thanks
M$
|
|
|
|
|
VB does it by reading the type library (typelib) that is included in the DLL with the COM object that you have. I have never really messed with the typelib directly, but maybe that will get you started on your search.
|
|
|
|
|
Look into the ITypeLib, ITypeLib2 and ITypeInfo.
Using these interafaces you can enumerate the
contents of a typelibrary.
|
|
|
|
|
I am working on some ATL objects that are called from an ASP page. Is there anyway to redefine ATLASSERT to do something else or nothing so it doesn't hang the server when it throws the dialog box?
TIA!
|
|
|
|
|
If it's just a macro, then just #define it to do nothing, after including the header that defines it to start with.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
It compiles to nothing when you compile in release mode.
|
|
|
|
|
Thanks! However, I have been using debug builds and switching between a GUI app so I can step through code and the ASP pages. I missed redefining if after the header, I was trying to do it before the include. That redifined the macro however I am still getting assertion dialogs somewhere. Do you guys know off the top of you head any other assert macros that would get called from the ATL internals?
Thanks again!
|
|
|
|
|
ATL makes heavy use of ATLASSERT internally.
|
|
|
|
|
#ifdef ATLASSERT
#undef ATLASSERT
#endif
#define ATLASSERT ....
Michel
If I am wrong or said something stupid, I apologize in advance
|
|
|
|