|
Harold_Wishes wrote: display them on the screen?
I don't believe any Regular Expression Engine will know anything about displaying results on a screen.
Harold_Wishes wrote: can search patterns in a file
It is also unlikely that a Regular Expression Engine will know about searching files.
Harold_Wishes wrote: built-in Regular expressions algorhythm
Regular Expressions are not part of the ISO C++ standard... yet. There is a Regular Expression Library in Boost (boost.org)
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
I am trying to create a dynamic string array m_pSentences[iLineCount], where iLineCOunt is the number of lines in a text file.
What should the synthax be?
Error:
(35): error C2440: '=' : cannot convert from 'char (*)[1000]' to 'char *'
Code:
char strSentence [MAX_SENTENCES_PER_FILE + 1] [MAX_CHARS_PER_SENTENCE + 1] = {""};
char strFileToRead[MAX_FILEPATH_LENGTH + 1] = {"c:\\temp\\testfile.txt"};
int iLineCount = 0;
// read the file and update temporary array
fstream file_op(strFileToRead, ios::in);
while(!file_op.eof())
{
file_op.getline(strSentence[iLineCount], MAX_CHARS_PER_SENTENCE);
iLineCount++;
}
file_op.close();
// create an array of sentences
char *m_pSentences;
m_pSentences = new char[iLineCount + 1] [MAX_CHARS_PER_SENTENCE];
for (int iIndex = 0; iIndex <= iLineCount; iIndex++)
{
strcpy(strSentence[iIndex], m_pSentences);
//m_pSentences[iIndex] = *strSentence[iIndex];
}
for (int iIndex = 0; iIndex <= iLineCount; iIndex++)
{
cout << m_pSentences[iIndex] << endl;
}
delete [] m_pSentences;
}
Jon
|
|
|
|
|
char *m_pSentences[MAX_SENTENCES_PER_FILE];
but, you'd be much better off using CString or std::string and some kind of container class:
vector< std::string > sentences;
sentences.push_back("this is sentence 1.");
sentences.push_back("this is sentence 2.");
or
CStringArray sentences;
sentences.Add("this is sentence 1.");
sentences.Add("this is sentence 2.");
messing around with multi-dim arrays is more trouble than it's worth, in most cases.
Do the chickens have large talons?
-- modified at 22:42 Monday 17th July, 2006
|
|
|
|
|
Chris Losinger wrote: messing around with multi-dim arrays is more trouble than it's worth, in most cases.
What is it worth?
|
|
|
|
|
it's worth knowing how multi-dim arrays work. not everything can (or should) be put into a vector - strings definitely should.
Do the chickens have large talons?
|
|
|
|
|
Chris Losinger wrote: it's worth knowing how multi-dim arrays work
Trixy answer... I like it!
|
|
|
|
|
I’m trying to create a function that creates an array of strings when reading from a text file.
This object seems to require afxcoll.h to be included and I've included them in my console application, however a couple of errors crop up. I also tried to include it within an MFC application, since this is an MFC class, but they won't compile as well.
Sentences error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in libcpd.lib(newop.obj)
Sentences error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCD.lib(dbgdel.obj)
Sentences error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in LIBCD.lib(delete2.obj)
Sentences error LNK2019: unresolved external symbol __endthreadex referenced in function "void __stdcall AfxEndThread(unsigned int,int)" (?AfxEndThread@@YGXIH@Z)
Sentences error LNK2019: unresolved external symbol __beginthreadex referenced in function "public: int __thiscall CWinThread::CreateThread(unsigned long,unsigned int,struct _SECURITY_ATTRIBUTES *)" (?CreateThread@CWinThread@@QAEHKIPAU_SECURITY_ATTRIBUTES@@@Z)
Code (to test):
CStringArray strSentences;
strSentences.Add("mary");
strSentences.Add("george");
Any idea why?
Jon
|
|
|
|
|
looks like you're mixing different versions of the C run-time libraries - one or more files in your app are compiled with the single-threaded CRT, but others are built with a different CRT. "new" and "delete" are defined in both, and the linker doesn't know which one to use. so, make all your files/modules/libraries use the same CRT version.
Do the chickens have large talons?
|
|
|
|
|
How would I check the CRT version?
Also, why is the following error being displayed?
Error
.cpp(17): fatal error C1010: unexpected end of file while looking for precompiled header directive
Code example:
#include ".\SentenceAr.h"
#include <string>
#include <iostream>
CSentenceArray::CSentenceArray(string strFileToRead, bool bCreateArray)
{}
CSentenceArray::~CSentenceArray()
{};
Jon
|
|
|
|
|
jon_80 wrote: How would I check the CRT version?
two different places:
project Properties (or Settings) General / Microsoft Foundation Classes
or, C/C+ / Category:Code Generation / Use Run-time Library.
that's VC6. VS03/05 are in similar places.
jon_80 wrote: Also, why is the following error being displayed?
you need to add #include "stdafx.h" to the top of the file.
Do the chickens have large talons?
|
|
|
|
|
Does the project have to be an MFC project or can I include the MFC classes by including files?
I am using a console project to develop the classes because the code is simpler to test that way.
I have tried all the options within VS2003 for Run-time library but the code wouldn't compile in any case.
Also, I could not find stdafx.h, is it because it's not an MFC project?
Jon
|
|
|
|
|
jon_80 wrote: Does the project have to be an MFC project or can I include the MFC classes by including files?
it's far easier to do it from a project that was created to work with MFC than it is to add MFC after the fact. i'm not sure of all the steps, but you'll need to #include some stuff, set some #defines for the compiler, link the appropriate MFC libs, etc..
if you already have a non-MFC project, you might be better off with using std::string and std::vector:
#include < string>
#include < vector>
using namespace std;
...
vector < string > sentences;
sentences.push_back("this is a sentence");
sentences.push_back("this is another sentence");
...
string s = sentences[0];
etc.
Do the chickens have large talons?
|
|
|
|
|
|
Hi fellows
I`m trying to create a treeview in my app but I don`t have any sucess.
I`ve read the Microsoft article [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/treeview/treeview.asp[/url]
and I`ve tried to do something like that. The problem is that whem I create a node in a function that I created it returns NULL. I think that my code is right, so what`s going on??
Thanks for the support.
Below is my code?
I created my treeview like this:
<br />
treeViewHwnd = CreateWindowEx(WS_EX_LEFT, WC_TREEVIEW, "theTreeView", WS_CHILD|WS_VISIBLE|TVS_EDITLABELS|TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT, 0, 0, 150, 600, hwnd, NULL, hCurrentInstance, NULL);<br />
treeViewHwnd is a global HWND.
In this part I want to put a node in the treeview
<br />
case WM_CHAR:<br />
{<br />
switch(wParam)<br />
{<br />
case 'a':<br />
{<br />
InitCommonControls();<br />
treeViewHwnd = GetDlgItem(hwnd, IDC_TREE1);<br />
OpenedWindows(GetForegroundWindow());<br />
for(int i = 0 ; i < sNameHwnds.size() ; i++)<br />
{ <br />
InsertNodeInTV(hwnd, sNameHwnds[i], 1);<br />
MessageBox(NULL, sNameHwnds[i].c_str(), "", MB_OK);<br />
break;<br />
}<br />
break;<br />
}<br />
.....<br />
And here I create the node:
<br />
#define IDC_TREE1 10<br />
HTREEITEM InsertNodeInTV(HWND tvHwnd, string sNodeName, int iLevel)<br />
{<br />
static HTREEITEM ParentItem, BeforeItem, RootItem;<br />
ParentItem = (HTREEITEM)TVI_FIRST;<br />
BeforeItem = RootItem = NULL;<br />
TVINSERTSTRUCT treeViewInsert;<br />
treeViewInsert.item.mask = TVIF_TEXT;<br />
treeViewInsert.item.pszText = (char*)sNodeName.c_str();<br />
treeViewInsert.item.cchTextMax = sizeof(treeViewInsert.item.pszText)/treeViewInsert.item.pszText[0];<br />
treeViewInsert.hInsertAfter = TVI_ROOT;<br />
treeViewInsert.hParent = NULL;<br />
ParentItem = (HTREEITEM)SendDlgItemMessage(tvHwnd, IDC_TREE1, TVM_INSERTITEM, 0, (LPARAM)&treeViewInsert);<br />
if(ParentItem == NULL)MessageBox(NULL, "aaa", "", MB_OK);<br />
return ParentItem;<br />
}<br />
|
|
|
|
|
Besides the fact that "int iLevel" is not used the rest of the code runs correctly when I have good values like tvHwnd, IDC_TREE1, etc. Therefore I suspect one of your values is incorrect.
|
|
|
|
|
cchTextMax = sNodeName.size()
Kuphryn
|
|
|
|
|
Wow... how did i miss that
|
|
|
|
|
Dear all,
I have MFC application Which As button named Download file ,which pop up a user dialog named "file download". which provides buttons to browse file and start downloading the selected file.
When i press download button it call a dll function to perform the download operation and waits for download to complete.what i need is to close the dialogbox(named file download)whenever the file download completed messagebox pop up .
Manjunath S
GESL
Bangalore
|
|
|
|
|
|
If it's a modal dialog, call EndDialog() . If it's modeless, call DestroyWindow() .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
and you can se WM_DESTROY
whitesky
|
|
|
|
|
Using the designer to create the main form for an application generated the following code in the .cpp file:
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threading::Thread::CurrentThread->ApartmentState = System::Threading::ApartmentState::STA;
Application::Run(new DataForm(lpCmdLine));
return 0;
}
The DataForm class has a button which generates a new form:
linkedForm = new LinkedForm() ;
The LinkedForm class exists in the same namespace as the DataForm class.
What needs to be done to allow this child form to see public methods in it's parent, since a DataForm ptr cannot be declared globally? Are there any examples of parent/child form communications of this nature?
Thanks,
MrHonus
|
|
|
|
|
seems this is not a standard MFC program, u might post it to Manage C++/CLI forum.
life is like a box of chocolate,you never know what you r going to get.
|
|
|
|
|
|
Is it CI/C++?
It was created using Visual Studio and .NET, so I guess the answer is yes.
|
|
|
|