|
May I ask what would you do if you were trying to accomplish this task?
Thank you
|
|
|
|
|
Christan's approach might work, if you are looking to split a normal string into tokens by normal whitespace (tabs and spaces).
I would need to know more about what you are trying to do in order to offer a possibly more-optimal solution.
For example, if you are building a tokenizer, you might want to build something using (f)lex . If you are counting words in a small file, strtok(...) with a local buffer may work, if using a large file, skipping characters manually with a memory mapped file may work better, etc.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hi James:
"For example, if you are building a tokenizer, you might want to build something using (f)lex. If you are counting words in a small file, strtok(...) with a local buffer may work, if using a large file, skipping characters manually with a memory mapped file may work better, etc."
Your comments are way above my head. I just started learning C++ two weeks ago. Having said that, I do have some knowledge on C programming.
What I try to achieve is simply to produce a "concordance" program using C++. I need to count every word from a text file and make a record of where they are.
First of all, I need to read a word at one time from this text file in the way I described before. I am not so sure now which "string" function I am going to use in order to achieve my goal.
Thank you
|
|
|
|
|
C_Zealot wrote: Your comments are way above my head. I just started learning C++ two weeks ago.
That is OK! :P I sometimes do not understand my audience...
Using Christan's approach may be best for you because it (1) is simple and (2) it works (well enough).
I am not sure how his example will handle punctuation, so be aware. In other words, I do not know if the following string:
This is a simple-string, I think... Will return 6 items:
This is a simple-string, I think... -Or 12 items:
This is a simple - string , I think . . . -Or some value in between. You will need to experiment to make sure it is working correctly for your needs. I am guessing that it will only react to spaces and return 6, and I think that behavior can be changed, but always best to make sure...
Good luck!
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
C_Zealot wrote: Your comments are way above my head. I just started learning C++ two weeks ago. Having said that, I do have some knowledge on C programming.
Then stick with what you have, whether it is optimal or not. Making code optimal and efficient will come with time and experience. Get you logic down and make it understandable.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
#include < iostream >
#include < string >
using namespace std;
ifstream in("myfile.txt", ios::in);
if(in.good())
{
string strWord;
while(!in.eof())
{
strWord << in;
}
}
Something like that should work for what you want to do. You can even change the ifstream to split on something other than whitespace by calling one of it's functions.
See this for more reference:
http://www.cplusplus.com/reference/iostream/ifstream/[^]
Just noticed you wanted this function prototype:
std::string readWord(ifstream& in)
{
string s = "";
if(in.good())
{
s << in;
}
return s;
}
|
|
|
|
|
hai,
Any one please tell how to get the position in integer values of selected item in ClistControl
Thanks In Advance
Jannath
|
|
|
|
|
int index=m_List.GetNextItem(-1,LVNI_SELECTED);
|
|
|
|
|
|
|
Since you mention values and not value, I am presuming that you are looking for multiple selected items, so I would recommend using CListCtrl::GetFirstSelectedItemPosition(...) and CListCtrl::GetNextSelectedItem(...) .
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
i mean a single value.i am selecting a single value & i want the exact position of that item in the list
Thanks in Advance
|
|
|
|
|
Whitesky's approach is more direct and will work well, but note that my above will also work for single selected items (or for nothing selected as well).
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Your answer is perfect.
|
|
|
|
|
On a button press in dialog i am Creating a thread by the statement
pTh = new CMyThread;
Where CMyThread is CWinThread derived class and pTh is declared in the MyDialg.h as
CMyThread *pTh
Even though i close the dialog can my thread run without any issues. Are there any points that i should note in this senario.
Thank you.
KIRAN PINJARLA
|
|
|
|
|
jup, the Thread is still alive
you should kill him in the OnClose-Method via pTh->PostThreadMessage(WM_QUIT);
|
|
|
|
|
The thread will copy some files from one location to another. It will automatically end when its done.
My question is
Does the thread complete its work eventhough i close my dialog.
KIRAN PINJARLA
|
|
|
|
|
I'm not an expert, but i think yes
But you can test it via OutputDebugMessage("STILL ALIVE");
Then you give your thread a hard work and close directly the dialog.
Propably the debugger kills the thread for you.
|
|
|
|
|
kiran.pinjarla wrote: Even though i close the dialog can my thread run without any issues.
Yes, your thread runs independantly of the dialog box.
kiran.pinjarla wrote: Are there any points that i should note in this senario.
You should make sure that all threads have ended before the application terminates. It's considered good practice.
Read here[^] and here[^] for information about how to accomplish this.
Usually you would like your main thread to know when your secondary thread has finished its work and I suggest you post a user defined message to do that.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
How can i get sharing properties of a file/folder ?
There are inodes in unix fs , what matches inodes in NTFS , and which system calls should i use to get
inode number of a file/folder ?
Thank you very much.
|
|
|
|
|
check GetNativeSystemInfo()
nave
|
|
|
|
|
|
Akin Ocal wrote: There are inodes in unix fs , what matches inodes in NTFS , and which system calls should i use to get
inode number of a file/folder ?
Given that an inode stores, among other things, information such as user and group ownership, look at GetFileSecurity() and GetNamedSecurityInfo() . An inode also stores a file's attributes, so check out GetFileAttributes() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
S.V.RAJKUMAR wrote: I need to call that method or function by multithreadingly?
Why?
S.V.RAJKUMAR wrote: In VB, What is the Method to call this function multitaskingly?
VB6 doesn't allow multithreading.
VB.NET allows it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|