|
kitty5 wrote: I wouldn't need to use new(), correct?
you would most certainly use new[] with an array that large. it's bad practice to put such a large array on the stack.
|
|
|
|
|
Chris Losinger wrote: you would most certainly use new[] with an array that large. it's bad practice to put such a large array on the stack.
if it's a double array would you do:
<br />
ULONG *buff;<br />
buff = new ULONG [1000][1000];<br />
do I access buff the same as an array?
i.e. buff[0][10] = 0x12345678;
Thanks!
Kitty5
|
|
|
|
|
kitty5 wrote: do I access buff the same as an array?
yes
|
|
|
|
|
The following code is intended to clear garbage from a fixed array of strings, however I am getting the following errors, the first of which (I think) is the most relevant:
SentenceAr.cpp(13): error C2440: '=' : cannot convert from 'const char [1]' to 'char'
SentenceAr.cpp(20): error C2144: syntax error : 'void' should be preceded by ')'
SentenceAr.cpp(20): error C2059: syntax error : ')'
SentenceAr.cpp(21): error C2143: syntax error : missing ';' before '{'
SentenceAr.cpp(23): error C2601: 'CSentenceAr::readFromFile' : local function definitions are illegal
SentenceAr.cpp (extract)
CSentenceAr::CSentenceAr(char strFileToRead[MAX_FILENAME_LENGTH + 1])
{
// Initialize strSentence
{ for (int iLineNumber = 1; iLineNumber <= MAX_LINES; iLineNumber++)
{
for (int iCharPos = 1; iCharPos <= MAX_SENTENCE_LENGTH; iCharPos++)
{strSentence[iLineNumber] [iCharPos] = "";}
}
readFromFile(strFileToRead);
}
...
SentenceAr.h
#define MAX_LINES 100
#define MAX_SENTENCE_LENGTH 1000
#define MAX_FILENAME_LENGTH 40
#define MAX_WORD_LENGTH 10
class CSentenceAr
{
public:
CSentenceAr(char strFileToRead[MAX_SENTENCE_LENGTH + 1]);
virtual ~CSentenceAr(void);
void sortSentences(bool bAscending); // implements BubbleSort
int HowManyWords(char strWord[MAX_WORD_LENGTH + 1]);
char strSentence [MAX_LINES + 1] [MAX_SENTENCE_LENGTH + 1];
private:
void readFromFile(char strFileToRead[MAX_SENTENCE_LENGTH + 1]);
};
SentenceAr.cpp (whole)
#include ".\SentenceAr.h"
#include <fstream>
using namespace std;
CSentenceAr::CSentenceAr(char strFileToRead[MAX_FILENAME_LENGTH + 1])
{
// Initialize strSentence
{ for (int iLineNumber = 1; iLineNumber <= MAX_LINES; iLineNumber++)
{
for (int iCharPos = 1; iCharPos <= MAX_SENTENCE_LENGTH; iCharPos++)
{strSentence[iLineNumber] [iCharPos] = "";}
}
readFromFile(strFileToRead);
}
CSentenceAr::~CSentenceAr(void)
{}
void CSentenceAr::readFromFile(char strFileToRead[MAX_FILENAME_LENGTH + 1])
{
char strLine[MAX_SENTENCE_LENGTH + 1];
short iLineNumber = 1;
fstream fileToRead(strFileToRead,ios::in);
while (!fileToRead.eof())
{ fileToRead.getline(strLine, MAX_SENTENCE_LENGTH);
// copy strLine to strSentence for each iLineNumber
for (int iCharPos = 1; iCharPos <= MAX_SENTENCE_LENGTH; iCharPos++)
{
strSentence[iLineNumber] [iCharPos] = strLine[iCharPos];
}
iLineNumber++;
}
}
}
Jon
|
|
|
|
|
My guess is that you need to do some reading on what C style strings are. Any good reason why you are not using std::vector and std::string?
Arrays start at index 0. Why do you allocate more memory just to get it to start at index 1? Just do strSentence[iLineNumber-1] when accessing your array.
for (int iLineNumber = 0; iLineNumber < MAX_LINES; iLineNumber++)
{
strSentence[iLineNumber][0] = '\0';
}
char strSentence[MAX_LINES][MAX_SENTENCE_LENGTH + 1];
Use strcpy instead. Code below is an idea of what strcpy is doing. This is why C style strings are refered to as NUL ('\0') terminated.
int iCharPos = 0;
while(strLine[iCharPos] != '\0')
{
strSentence[iLineNumber][iCharPos] = strLine[iCharPos];
iCharPos++;
}
strSentence[iLineNumber][iCharPos] = '\0';
-- modified at 10:28 Sunday 23rd July, 2006
|
|
|
|
|
how can i implement the NM_CUSTOMDRAW message for the default Toolbar for an MDI application (toolbar ID = IDR_MAINFRAME) ?
thanks in advance ..
k_dehairy
|
|
|
|
|
See Here[^] maybe it is some helpful to you
|
|
|
|
|
I already drived a class from the CToolBar and implemented the
ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)
within it, and it worked fine untill I implemented the xp theme manifest in the application!!
why is that? I don't know? .. I need help on that
thanks very much for your care .. really
k_dehairy
|
|
|
|
|
I see this problem when i use manifest in app (of course i use combobox derived)
|
|
|
|
|
Hi,
I am looking for an example of a CListCtrl derived class
which implements static columns. These are columns which
are excluded from a horizontal scroll, so it is possible
to scroll horizontal through a large list control, leaving
some important columns permanently in view. Can anybody help
me to a link or say how exactly it is done.
tia.
|
|
|
|
|
Did you see examples from Listctrl in codeproject
|
|
|
|
|
No, cann't find any examples.
|
|
|
|
|
|
I am trying to read a file and write its contents to a listbox control.
However, the listbox control variable is not recognized within the 'click' event of the button.
void CSentenceTestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_DISPLAY, m_Display); // m_Display is the control variable for the listbox
}
...
void CSentenceTestDlg::OnBnClickedTest()
{
//m_Display returns a synthax error when typed here!!
}
Jon
|
|
|
|
|
Can you be more specific ON_LBN_SELCHANGE(IDC_LIST2, OnLbnSelchangeList2) when you click
in a listbox you have a event ON_LBN_SELCHANGE now what do you need
|
|
|
|
|
How to get creation time of a contact in Outlook Express?
|
|
|
|
|
i need some projects in VC,related to sound processing
http://www.engineeringproject.net
|
|
|
|
|
You can search in codeproject and find your answer what do you need?
|
|
|
|
|
no have searched.
i need algorithm for pcm mixing
http://www.engineeringproject.net
|
|
|
|
|
Hi, I am a newbie to WinAPI. I have 2 projects in one workspace: 1 has a window handle, is there a way of accessing this window handle in the second project?
|
|
|
|
|
|
|
quziguang wrote:
Thanks, it works!
EnumWindow!
"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
Support CRY- Child Relief and You
|
|
|
|
|
dear all,
Please help me how to delete all files or how to get the file names of all files in a directory.
I know a method in UNIX. But I need to do in Windows environment. I'm using VC++ 6.0.
Same as in UNIX, can I use (DIR structure) or different method should be followed?
Thanks in advance.
Raja Pratap.
|
|
|
|
|