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.
thanks again David.. with ur guidance i succeded in completing the project...
my exe is workin fine... iam able to save the contents of editox to text file and import the data from the same text file....
thanking u once again...
Hello, in my aplication there are two dialogs CCalibracionDlg and DlgMap1 both derived from Cdialog, when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this?
I've been trying to do this with PostMessage(hWnd, WM_MYCUSTOMMESSAGE,(WPARAM) wParam,(LPARAM) lParam ); or SendMessage , but in DlgMap1 how can i get the hWnd to CCalibracionDlg?
Thanks in advance.
well i dont think sendMessage is a good option if they are belonging to the same application and thread.
one method will be use FindWindowEx, that give you the handle if you specify the name of the dialog.
CCalibracionDlg and DlgMap1 both derived from Cdialog, when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this?
I've been trying to do this with PostMessage(hWnd, WM_MYCUSTOMMESSAGE,(WPARAM) wParam,(LPARAM) lParam ); or
Better to have an 'object' or pointer of CCalibracionDlg in DlgMap1.U can get handle through object.GetSafeHWND(). Or Simply u can call object.SendMessage(..) or object.PostMessage()
Last Visit: 31-Dec-99 18:00 Last Update: 26-Sep-23 8:32