Click here to Skip to main content
15,899,679 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Testing a dll Pin
Eytukan22-Jul-06 5:01
Eytukan22-Jul-06 5:01 
GeneralRe: Testing a dll Pin
Hamid_RT22-Jul-06 7:15
Hamid_RT22-Jul-06 7:15 
QuestionMFC application crash when using activex control Pin
eranre22-Jul-06 1:07
eranre22-Jul-06 1:07 
AnswerRe: MFC application crash when using activex control Pin
A_Fa22-Jul-06 1:27
A_Fa22-Jul-06 1:27 
AnswerRe: MFC application crash when using activex control Pin
Hamid_RT22-Jul-06 7:14
Hamid_RT22-Jul-06 7:14 
QuestionCreateFile API Hook [modified] Pin
capricious_00122-Jul-06 0:15
capricious_00122-Jul-06 0:15 
AnswerRe: CreateFile API Hook Pin
Stephen Hewitt22-Jul-06 0:30
Stephen Hewitt22-Jul-06 0:30 
QuestionReading from a text file (2 q's) Pin
jon-8021-Jul-06 23:34
professionaljon-8021-Jul-06 23:34 
1. I’m trying to create an MFC library, the constructor of which reads from a file and updates an array.

CSentenceAr.h
#pragma once
#include <iostream>

class CSentenceAr
{
public:
CSentenceAr(LPCTSTR strFileToRead);
virtual ~CSentenceAr(void);
void sortSentences(bool bAscending);
int HowManyWords(const CString *pszWord);
private:
CStringArray m_strSentences;
};

#include "StdAfx.h"
#include ".\sentencear.h"


#define MAX_SENTENCES_PER_FILE 100
#define MAX_SENTENCE_LENGTH 1000

CSentenceAr.cpp

CSentenceAr::CSentenceAr(LPCTSTR strFileToRead)
{
CFile fileOp;

fileOp.Open(strFileToRead, CFile::modeCreate|CFile::modeRead);


char strLine[MAX_SENTENCE_LENGTH];
fileOp.Read(strLine,MAX_SENTENCE_LENGTH);
m_strSentences.Add(strLine);
}

CSentenceAr::~CSentenceAr(void)
{
}

I would like to read it line by line. Will the .Read method read the file to the end? How do I include the library file (preferably as a .dll, so I can add it as a reference) within another project to test it?

2. I tried to add an fstream object within this dll, but the compiler was returning the following error:

SentenceAr.cpp(12): error C2065: 'fstream' : undeclared identifier


Code:
#include "StdAfx.h"
#include ".\sentencear.h"
#include <fstream>


#define MAX_SENTENCES_PER_FILE 100
#define MAX_SENTENCE_LENGTH 1000

CSentenceAr::CSentenceAr(LPCTSTR strFileToRead)
{
CFile fileOp;
fstream mydamnFile;



fileOp.Open(strFileToRead, CFile::modeCreate|CFile::modeRead);


char strLine[MAX_SENTENCE_LENGTH];
fileOp.Read(strLine,MAX_SENTENCE_LENGTH);
m_strSentences.Add(strLine);
}

CSentenceAr::~CSentenceAr(void)
{
}




Jon
AnswerRe: Reading from a text file (2 q's) Pin
Garth J Lancaster22-Jul-06 0:36
professionalGarth J Lancaster22-Jul-06 0:36 
GeneralRe: Reading from a text file (2 q's) Pin
ovidiucucu22-Jul-06 1:36
ovidiucucu22-Jul-06 1:36 
GeneralRe: Reading from a text file (2 q's) Pin
Garth J Lancaster22-Jul-06 2:08
professionalGarth J Lancaster22-Jul-06 2:08 
GeneralRe: Reading from a text file (2 q's) Pin
ovidiucucu22-Jul-06 3:35
ovidiucucu22-Jul-06 3:35 
AnswerRe: Reading from a text file (2 q's) Pin
ovidiucucu22-Jul-06 1:33
ovidiucucu22-Jul-06 1:33 
GeneralThanks for the solution Pin
jon-8022-Jul-06 2:07
professionaljon-8022-Jul-06 2:07 
QuestionConvert C++ strings to C-style string (char*) in VC++ 6.0 Pin
Dhananjayak0221-Jul-06 23:31
Dhananjayak0221-Jul-06 23:31 
AnswerRe: Convert C++ strings to C-style string (char*) in VC++ 6.0 Pin
Stephen Hewitt22-Jul-06 0:35
Stephen Hewitt22-Jul-06 0:35 
AnswerRe: Convert C++ strings to C-style string (char*) in VC++ 6.0 Pin
Naveen22-Jul-06 0:38
Naveen22-Jul-06 0:38 
AnswerRe: Convert C++ strings to C-style string (char*) in VC++ 6.0 Pin
Eytukan22-Jul-06 5:11
Eytukan22-Jul-06 5:11 
GeneralRe: Convert C++ strings to C-style string (char*) in VC++ 6.0 Pin
Dhananjayak0222-Jul-06 8:43
Dhananjayak0222-Jul-06 8:43 
AnswerRe: Convert C++ strings to C-style string (char*) in VC++ 6.0 Pin
ThatsAlok23-Jul-06 21:19
ThatsAlok23-Jul-06 21:19 
Questionchange image resolution Pin
QuickDeveloper21-Jul-06 22:33
QuickDeveloper21-Jul-06 22:33 
AnswerRe: change image resolution Pin
Naveen21-Jul-06 23:13
Naveen21-Jul-06 23:13 
AnswerRe: change image resolution Pin
Hamid_RT21-Jul-06 23:36
Hamid_RT21-Jul-06 23:36 
AnswerRe: change image resolution Pin
ThatsAlok23-Jul-06 21:18
ThatsAlok23-Jul-06 21:18 
Questionhide a process! Pin
farshad.f21-Jul-06 22:24
farshad.f21-Jul-06 22:24 

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.