Click here to Skip to main content
16,007,843 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to know whether a file is saved or not Pin
led mike17-Aug-06 10:24
led mike17-Aug-06 10:24 
GeneralRe: How to know whether a file is saved or not Pin
Jijo.Raj17-Aug-06 14:55
Jijo.Raj17-Aug-06 14:55 
GeneralRe: How to know whether a file is saved or not Pin
Hamid_RT18-Aug-06 6:43
Hamid_RT18-Aug-06 6:43 
QuestionLPTSTR to char* Pin
georgekjolly17-Aug-06 6:51
georgekjolly17-Aug-06 6:51 
AnswerRe: LPTSTR to char* Pin
led mike17-Aug-06 6:55
led mike17-Aug-06 6:55 
QuestionRe: LPTSTR to char* Pin
David Crow17-Aug-06 6:55
David Crow17-Aug-06 6:55 
AnswerRe: LPTSTR to char* Pin
Zac Howland17-Aug-06 6:57
Zac Howland17-Aug-06 6:57 
Questionc++ Pin
jon-8017-Aug-06 6:05
professionaljon-8017-Aug-06 6:05 
CGenericList.Clear method should clear the contents of m_Data from the memory heap. This is done because strdup is called to create a duplicate of the string in a linked list so that data is not overwritten.

However, should CGenericList be of type int the Clear method would not compile since it does not take int types as parameters:

GenericList.h(32): error C2664: 'free' : cannot convert parameter 1 from 'int' to 'void *'


SentenceList.cpp
---------------------------------------------------------------------
CSentenceList::CSentenceList(char strFileToRead[MAX_SENTENCE_LENGTH + 1], bool bSorted)
: CGenericList<char*> ()
...
void CSentenceList::readFile(char strFileToRead[MAX_FILENAME_LENGTH])
{
char strLine[MAX_SENTENCE_LENGTH + 1];

fstream fileToRead(strFileToRead,ios::in);

while (!fileToRead.eof() && Size < MAX_LINES)
// Read line of text from file and update Sentences.strSentence.
{ fileToRead.getline(strLine, MAX_SENTENCE_LENGTH);
Sentences.Insert(strdup(strLine));
Size++;
}
fileToRead.close();

}
...

GenericList.h
---------------------------------------------------------------------
template<class T>
class CGenericList

void Clear() // empties the list
{

CGenericNode<T> *pTemp = m_pFirst;

// clear the data
while(pTemp != NULL)
{
CGenericNode<T> *pRemember = pTemp->m_pNextNode;
free (pTemp->m_data);
pTemp = pRemember;
}

// clear the nodes
while(pTemp != NULL)
{
CGenericNode<T> *pRemember = pTemp->m_pNextNode;
delete pTemp;
pTemp = pRemember;
}

m_iCount = 0;
}

Is it wise and possible to say, for example:

if typeof(<T>) == char*
// Clear the data
...
free (pTemp->m_data);
...

Alternatively how can I loop through the methods from the derived class, in this case, CSentenceList?

Jon
AnswerRe: c++ Pin
Zac Howland17-Aug-06 6:13
Zac Howland17-Aug-06 6:13 
GeneralRe: c++ Pin
jon-8017-Aug-06 8:02
professionaljon-8017-Aug-06 8:02 
GeneralRe: c++ Pin
Zac Howland17-Aug-06 8:16
Zac Howland17-Aug-06 8:16 
GeneralRe: c++ Pin
jon-8018-Aug-06 9:01
professionaljon-8018-Aug-06 9:01 
QuestionLinking Error /outportb Pin
cahit2317-Aug-06 5:55
cahit2317-Aug-06 5:55 
AnswerRe: Linking Error /outportb Pin
kakan17-Aug-06 20:48
professionalkakan17-Aug-06 20:48 
Questionproblems with winsock Pin
afpr17-Aug-06 5:43
afpr17-Aug-06 5:43 
AnswerRe: problems with winsock Pin
lucy17-Aug-06 5:47
lucy17-Aug-06 5:47 
GeneralRe: problems with winsock [modified] Pin
afpr17-Aug-06 6:04
afpr17-Aug-06 6:04 
GeneralRe: problems with winsock Pin
Zac Howland17-Aug-06 6:23
Zac Howland17-Aug-06 6:23 
GeneralRe: problems with winsock [modified] Pin
afpr17-Aug-06 6:26
afpr17-Aug-06 6:26 
GeneralRe: problems with winsock Pin
Zac Howland17-Aug-06 6:58
Zac Howland17-Aug-06 6:58 
GeneralRe: problems with winsock Pin
afpr17-Aug-06 8:16
afpr17-Aug-06 8:16 
GeneralRe: problems with winsock Pin
David Crow17-Aug-06 8:24
David Crow17-Aug-06 8:24 
GeneralRe: problems with winsock Pin
Zac Howland17-Aug-06 9:50
Zac Howland17-Aug-06 9:50 
GeneralRe: problems with winsock Pin
afpr17-Aug-06 10:33
afpr17-Aug-06 10:33 
GeneralRe: problems with winsock Pin
Zac Howland17-Aug-06 10:42
Zac Howland17-Aug-06 10:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.