Click here to Skip to main content
15,926,959 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: 2-d array of CStrings Pin
Roj23-Jul-06 19:30
Roj23-Jul-06 19:30 
Questionissues with Message pump handling [modified] Pin
act_x23-Jul-06 12:22
act_x23-Jul-06 12:22 
QuestionDialup connection with LAN on XP Pin
PJ Arends23-Jul-06 9:10
professionalPJ Arends23-Jul-06 9:10 
AnswerRe: Dialup connection with LAN on XP Pin
Maxwell Chen23-Jul-06 23:15
Maxwell Chen23-Jul-06 23:15 
GeneralRe: Dialup connection with LAN on XP Pin
PJ Arends24-Jul-06 7:06
professionalPJ Arends24-Jul-06 7:06 
QuestionWorking With USB to Parallel adapter Pin
McElwees23-Jul-06 8:44
McElwees23-Jul-06 8:44 
AnswerRe: Working With USB to Parallel adapter Pin
Trollslayer23-Jul-06 9:45
mentorTrollslayer23-Jul-06 9:45 
GeneralRe: Working With USB to Parallel adapter Pin
McElwees24-Jul-06 15:05
McElwees24-Jul-06 15:05 
QuestionEscape characters Pin
jon-8023-Jul-06 7:53
professionaljon-8023-Jul-06 7:53 
AnswerRe: Escape characters Pin
Michael Dunn23-Jul-06 8:53
sitebuilderMichael Dunn23-Jul-06 8:53 
AnswerRe: Escape characters Pin
Steve Echols23-Jul-06 17:52
Steve Echols23-Jul-06 17:52 
QuestionVirtual WebCam Pin
DobosCake23-Jul-06 7:17
DobosCake23-Jul-06 7:17 
AnswerRe: Virtual WebCam Pin
Justin Tay23-Jul-06 7:44
Justin Tay23-Jul-06 7:44 
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 

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.