When I pressed button OK, an excepiton will occur. Case 1 and case 3 are the same result. That is,
MyUnFilterA will be be called and a messagebox will pop up and show the text "11". And after the messagebox is closed, the application exits. Case 2 and case 2 are the same result. An error dialog will pop up first and ask me "Abort", "Retry" or "Ignore". If select "Retry", the message box "11" will show. Otherwise, the application will exit.
I think it's better pop up my defined message box first. What should I do?
That wont be a problem. If you use CStdioFile then it means you like to ReadString, it will help to read line by line of your file so easily as mentioned above.
But if you prefer to read chunk by chunk data then i prefer you to use Read itself.
The error is the program will just stop and ask me to debug, send error online or not.
It work when i change the CString txt to char* txt = new char[len+1]
but my output result is wrong. I am read some number with letter from a txt file. The txt file is quite big.
Ya, have been fighting with it for past 3weeks. I can't use fscanf cos i want to set some security. I don't want other user to open the file for reading/writing when my program is using it. Therefore i need to use CFile or CStdioFile. I change my code to
int len = f1.GetLength();
char* txt = new char[len+1];
while(_tscanf(txt, "%lf %lf %lf\n", &a, &b, &c) != EOF)
Using that, it work. But my output result is wrong. The file i am reading consist alot of number and a bit of letter. Thanks
Sorry if I dont know but is there any such option in CFile that is helping you to block reading/writing access to a file when you are using it and which is not possible with fscanf?
I am not saying what you are doing is impossible or wrong but I used the functions I mentioned before and they were very easy to use. I have never used CFile before. I never felt the need for it..
There must be some special use of CFile..
I am trying to make an exe which will save the data entered by user in a text format.
Its also possible to import the text file to the editbox.. I have four editboxes and these four will be having different data.. but once i store it in text format it will be in one file and during importing the complete data will be in all four edit boxes..
I want to filter out the data for specific editboxes while importing.. Editboxes are Critical, Important, Less Important and Normal.....
Can snybody help me how to filter out the specific data...
iam including my code here.. also my text format...plz hav a look and guide me...
thanku so much
If it's a professional app (which i feel is not the case), then you can use xml with four nodes and data for each node.
If you are making for learning purposes, then just insert a unique tag say <!!!TAG - 001!!!> and then dump all data for tag1. Similarly for tag2,3..
while reading data, search for <!!!TAG - 001!!!> and read data till you reach EOF or another TAG.
Now regarding searching of tags, use something like
while(*fp != '<') fp++;
if(fp == EOF) byebye.
if(read_next_9_characters() != "!!!TAG - ")
then read tag number and check for "!!!>" if it's present.
Read all data for current tag number and store.
Similarly for searching for another tags.
I am sure you can find many articles on searching string in a file in C/C++
An example is here [<a href="http://www.tutorialized.com/view/tutorial/Searching-for-a-string-in-a-File/9990" target="_blank">^</a>]
Other languages like python have built-in search capabilities for regular expressions search which makes this task very easy. other members can put more light on that.
by inserting a tag, I only meant writing some special string in a text file which has very little probability of appearing in the text entered by user. That tag serve as a flag that tells the reader of file that data for a different edit box begin here.