Click here to Skip to main content
15,924,829 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Virtual WebCam Pin
DobosCake23-Jul-06 8:49
DobosCake23-Jul-06 8:49 
GeneralRe: Virtual WebCam Pin
Justin Tay23-Jul-06 10:07
Justin Tay23-Jul-06 10:07 
AnswerRe: Virtual WebCam Pin
DobosCake23-Jul-06 23:48
DobosCake23-Jul-06 23:48 
Questionwhy use new() function in C++? Pin
kitty523-Jul-06 7:16
kitty523-Jul-06 7:16 
AnswerRe: why use new() function in C++? Pin
Chris Losinger23-Jul-06 10:03
professionalChris Losinger23-Jul-06 10:03 
GeneralRe: why use new() function in C++? Pin
kitty523-Jul-06 13:06
kitty523-Jul-06 13:06 
GeneralRe: why use new() function in C++? Pin
Chris Losinger23-Jul-06 14:11
professionalChris Losinger23-Jul-06 14:11 
QuestionArray of chars Pin
jon-8023-Jul-06 4:08
professionaljon-8023-Jul-06 4:08 
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
AnswerRe: Array of chars [modified] Pin
Justin Tay23-Jul-06 4:22
Justin Tay23-Jul-06 4:22 
QuestionNM_CUSTOMDRAW with the default ToolBar in MDI Pin
kdehairy23-Jul-06 1:39
kdehairy23-Jul-06 1:39 
AnswerRe: NM_CUSTOMDRAW with the default ToolBar in MDI Pin
Hamid_RT23-Jul-06 3:05
Hamid_RT23-Jul-06 3:05 
GeneralRe: NM_CUSTOMDRAW with the default ToolBar in MDI Pin
kdehairy27-Jul-06 7:42
kdehairy27-Jul-06 7:42 
GeneralRe: NM_CUSTOMDRAW with the default ToolBar in MDI Pin
Hamid_RT27-Jul-06 22:27
Hamid_RT27-Jul-06 22:27 
QuestionCListCtrl with static columns. Pin
paperke6723-Jul-06 1:35
paperke6723-Jul-06 1:35 
AnswerRe: CListCtrl with static columns. Pin
Hamid_RT27-Jul-06 7:25
Hamid_RT27-Jul-06 7:25 
GeneralRe: CListCtrl with static columns. Pin
paperke6729-Jul-06 2:29
paperke6729-Jul-06 2:29 
GeneralRe: CListCtrl with static columns. Pin
Hamid_RT29-Jul-06 2:55
Hamid_RT29-Jul-06 2:55 
QuestionListbox control variable ?? Pin
jon-8023-Jul-06 1:15
professionaljon-8023-Jul-06 1:15 
AnswerRe: Listbox control variable ?? Pin
Hamid_RT23-Jul-06 3:00
Hamid_RT23-Jul-06 3:00 
QuestionHow get all new contacts which are created after a given time Outlook Express? Pin
mpprasad23-Jul-06 0:17
mpprasad23-Jul-06 0:17 
Questionneed projects in VC++ Pin
premium122-Jul-06 21:28
premium122-Jul-06 21:28 
AnswerRe: need projects in VC++ Pin
Hamid_RT23-Jul-06 3:00
Hamid_RT23-Jul-06 3:00 
GeneralRe: need projects in VC++ Pin
premium123-Jul-06 5:42
premium123-Jul-06 5:42 
QuestionNewbie's WinAPI question Pin
q8q8q122-Jul-06 20:41
q8q8q122-Jul-06 20:41 
AnswerRe: Newbie's WinAPI question Pin
A_Fa22-Jul-06 21:26
A_Fa22-Jul-06 21:26 

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.