Click here to Skip to main content
15,889,992 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Modeless and Modal dalog window Pin
Dieter Hammer30-Mar-09 1:05
Dieter Hammer30-Mar-09 1:05 
Questiononerdrawn CTabCtrl with themes, different XP vs. vista? Pin
Dieter Hammer29-Mar-09 22:26
Dieter Hammer29-Mar-09 22:26 
QuestionRead diffrent formats file in MFC. Pin
Le@rner29-Mar-09 22:16
Le@rner29-Mar-09 22:16 
QuestionRe: Read diffrent formats file in MFC. Pin
CPallini29-Mar-09 22:26
mveCPallini29-Mar-09 22:26 
AnswerRe: Read diffrent formats file in MFC. Pin
Le@rner29-Mar-09 22:28
Le@rner29-Mar-09 22:28 
QuestionRe: Read diffrent formats file in MFC. Pin
CPallini29-Mar-09 22:40
mveCPallini29-Mar-09 22:40 
AnswerRe: Read diffrent formats file in MFC. Pin
Rajesh R Subramanian29-Mar-09 22:49
professionalRajesh R Subramanian29-Mar-09 22:49 
AnswerRe: Read diffrent formats file in MFC. Pin
Pankaj D.Dubey30-Mar-09 0:02
Pankaj D.Dubey30-Mar-09 0:02 
Hi Dude,

You try the following Code, hope it can help u reading the files.
Try to reduce the code, its too lengthy....

/****** This function is made to search a given string in the file and returns 1 or 0 *****/

int Search_Tag(char* input_line, char* tag_value)
{
int tag_len=0;
Flag=FAIL;
while(*input_line !='\n')
{
if(*tag_value=='\0')
break;
else
{
while(*tag_value!='\0')
{
if (*input_line==*tag_value)
{
input_line++;
tag_value++;
Flag=PASS;
}
else
{
Flag=FAIL;
input_line++;
tag_value++;
}
}
}
}

if(Flag==FAIL)
return FAIL;
else
return PASS;
}

/******This function searches the next occurance of the given string in the file******/

GetNext(FILE *ptr_read_file, char *str)
{
while(1)
{
fgets(line_buffer, 200, ptr_read_file); // read the input file line by line
if(Search_Tag(line_buffer, str))
{
break;
}
}
return 0;
}

/***** This function traverses through the whole file and gives the position of the given strings *****/

int Search(FILE *ptr_read_file, char *str1, char* str2)
{
while(1)
{
fgets(line_buffer, 200, ptr_read_file); // read the input file line by line
if(Search_Tag(line_buffer, str1))
{
GetNext(ptr_read_file, str2); //Find Second Parameter
break;
}
}
return 0;
}

/*********** Reading the File *************/
void CABCDlg::OnButton1()
{
// TODO: Add your control notification handler code here

ctr++;
if(ctr == 1)
{
fp1 = fopen("File 1.txt","r");
//if the file doesnot exist or cannot be opened then return
if(fp1 == NULL)
{
MessageBox("File Not found 'File 1.txt' Check source directory and try again...","Error",0);
ctr--;
return;
}
fp2 = fopen("File 1.txt","r");
fp3 = fopen("File 1.txt","r");

Search(fp3, "Object number: 2", "Message contents");
fgets(line_buffer, 200, fp3);

/*********** READ 1st Four Bits From the File *********/
for(i=0; i<4; i++)
{
msg[i] = (fgetc(fp3));
}
m_txt1 = msg;
UpdateData(FALSE);

}
}

** Similarly u can read the .csv(dot csv) files as well.
Note: Save the files in the same folder where .dsw was saved, to save the search time.

All the best Smile | :) Smile | :)

French is the language of love, for everything else there is c++ ...(anonymous)

AnswerRe: Read diffrent formats file in MFC. Pin
Hamid_RT30-Mar-09 1:47
Hamid_RT30-Mar-09 1:47 
QuestionPROGRAM TO FIND WHETHER A STRING IS ANAGRAM OR NOT TO SOURCE STRING Pin
abhishekriyer29-Mar-09 21:56
abhishekriyer29-Mar-09 21:56 
AnswerRe: PROGRAM TO FIND WHETHER A STRING IS ANAGRAM OR NOT TO SOURCE STRING Pin
CPallini29-Mar-09 22:25
mveCPallini29-Mar-09 22:25 
AnswerRe: PROGRAM TO FIND WHETHER A STRING IS ANAGRAM OR NOT TO SOURCE STRING Pin
Rajesh R Subramanian29-Mar-09 22:51
professionalRajesh R Subramanian29-Mar-09 22:51 
GeneralRe: PROGRAM TO FIND WHETHER A STRING IS ANAGRAM OR NOT TO SOURCE STRING Pin
abhishekriyer29-Mar-09 23:03
abhishekriyer29-Mar-09 23:03 
GeneralRe: PROGRAM TO FIND WHETHER A STRING IS ANAGRAM OR NOT TO SOURCE STRING Pin
Chandrasekharan P30-Mar-09 0:03
Chandrasekharan P30-Mar-09 0:03 
GeneralRe: PROGRAM TO FIND WHETHER A STRING IS ANAGRAM OR NOT TO SOURCE STRING Pin
abhishekriyer30-Mar-09 0:27
abhishekriyer30-Mar-09 0:27 
AnswerRe: PROGRAM TO FIND WHETHER A STRING IS ANAGRAM OR NOT TO SOURCE STRING Pin
Rajesh R Subramanian30-Mar-09 0:32
professionalRajesh R Subramanian30-Mar-09 0:32 
GeneralRe: PROGRAM TO FIND WHETHER A STRING IS ANAGRAM OR NOT TO SOURCE STRING Pin
Luc Pattyn30-Mar-09 1:28
sitebuilderLuc Pattyn30-Mar-09 1:28 
GeneralRe: PROGRAM TO FIND WHETHER A STRING IS ANAGRAM OR NOT TO SOURCE STRING Pin
Chandrasekharan P30-Mar-09 0:54
Chandrasekharan P30-Mar-09 0:54 
GeneralRe: PROGRAM TO FIND WHETHER A STRING IS ANAGRAM OR NOT TO SOURCE STRING Pin
David Crow30-Mar-09 4:06
David Crow30-Mar-09 4:06 
GeneralRe: PROGRAM TO FIND WHETHER A STRING IS ANAGRAM OR NOT TO SOURCE STRING Pin
Rajesh R Subramanian30-Mar-09 0:24
professionalRajesh R Subramanian30-Mar-09 0:24 
AnswerRe: PROGRAM TO FIND WHETHER A STRING IS ANAGRAM OR NOT TO SOURCE STRING Pin
Luc Pattyn30-Mar-09 1:31
sitebuilderLuc Pattyn30-Mar-09 1:31 
AnswerRe: PROGRAM TO FIND WHETHER A STRING IS ANAGRAM OR NOT TO SOURCE STRING Pin
josip cagalj30-Mar-09 1:35
josip cagalj30-Mar-09 1:35 
QuestionHow to get access right to Registry in Vista Pin
Nitheesh George29-Mar-09 21:54
Nitheesh George29-Mar-09 21:54 
AnswerRe: How to get access right to Registry in Vista Pin
Stuart Dootson29-Mar-09 23:26
professionalStuart Dootson29-Mar-09 23:26 
GeneralRe: How to get access right to Registry in Vista Pin
Nitheesh George30-Mar-09 3:12
Nitheesh George30-Mar-09 3:12 

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.