|
Hi Every body
How to read a comma seperated file in VC++
Thanks in advance
|
|
|
|
|
Use strtok[^]
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
marcdev wrote:
Use strtok[^]
Are you sure that strtok reads a file??
|
|
|
|
|
Obviously not, but the question is not how to read a file ... Maybe you need that I was more specific:
1st. Open the file.
2nd. Read each line putting it in a string.
3rd. Process the string using strtok to separate it by commas.
Is strtok useful now ?
Marc Soleda.
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
Hi
There may be other more elegant ways, but unless you are reading millions of entries, this works just fine. The char variable is read and then ignored, you only store or use the datx as you wish.
char separator;<br />
ifstream FileIn("C:\\SampleData\\divedata.dat");<br />
FileIn >> dat1 >> separator >> dat2 >> separator >> dat3 >> separator >> dat4;
Good luck
|
|
|
|
|
knapak wrote:
here may be other more elegant ways, but unless you are reading millions of entries, this works just fine. The char variable is read and then ignored, you only store or use the datx as you wish.
char separator;
ifstream FileIn("C:\\SampleData\\divedata.dat");
FileIn >> dat1 >> separator >> dat2 >> separator >> dat3 >> separator >> dat4;
This can hardly work!
Good luck
Agreed
|
|
|
|
|
It would be more useful if you could explain why this can hardly work and provide examples of the alternatives. I've used it extensively and had no problems at all, but if there's a good reason to do something else we would be very happy to oblige. Otherwise is just empty discourse. Every time you assign a value to a variable, it takes the new value. If the variable is not used at all, given it is a single char variable, virtually no memory is wasted... why wouldn't it work?
|
|
|
|
|
knapak wrote:
It would be more useful if you could explain why this can hardly work
Try this line with your code:
This,is,a comma seperated,line
|
|
|
|
|
Fine, if you are mostly writing programs that deal with strings of characters, I can see the problem. However, it seems that were are here talking about reading ONLY numeric data, in which case my approach won't fail and IS SIMPLER.
Nevertheless, if you think your solution is more "elegant" why don't you provide a more comprehensive response, something beyond "use this", with clear sample code.
Cheers
|
|
|
|
|
knapak wrote:
Nevertheless, if you think your solution is more "elegant" why don't you provide a more comprehensive response, something beyond "use this", with clear sample code.
Why not just look at (and re-use) something others have already done, at CodeProject or elsewhere?
XTokenString[^]
string tokenize[^]
|
|
|
|
|
for example:
DirA = "c:\windows\system"
DirB = "c:\private\doc"
A realtive to B = ..\..\private\doc
how to implement this?
thanks in advance.
|
|
|
|
|
it is just simple strings game.
remove starting part of the path which is identical for both paths,
then count number of remaining folders (RF#) in path A.
then relative path is "(../) x RF# / remaining part of path B".
i'm curious what would you need this for sounds like school homeword but it's holiday now
rrrado
|
|
|
|
|
Use PathCommonPrefix() .
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
|
thanks for all you guys .
|
|
|
|
|
Hi Friends,
Can u inform me how to use Date Time Picker control in dialog based SDK application(No MFC Support)?
Regards
Vinit
|
|
|
|
|
See here.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hi,
I have few controls and TabCtrl on it.
And when user select each tab i do ShowWindow(SW_SHOW) for few controls, and ShowWindow(SW_HIDE) for other controls. Every control is behind TabCtrl.
And ShowWindow(SW_SHOW) doesnt show my all controls which i would like to show.
TabCtrl covers few controls even i do SetFocus and ShowWindow(SW_SHOW) for controls.
Actualy only CDataTimePicker controls isn't be shown, Buttons and ComboBox work good (i mean doesn't be covered by TabCtrl when i send them ShoWindow(SW_SHOW)).\
I wpould like to show my controls, which are on TabCtrl ;/
//I dont use pages for tab, everything is on my one dialog.
Thanks a lot for help, i reall dont know what to do
Best Greetings for all
Michael
//I do GetDlgItem(IDC_DTPICKER1)->ShowWindow(SW_SHOW);
df
|
|
|
|
|
That's the wrong way!!!!
You have to create a child dialog with the controls on it for every page of the tab control. There are examples on CodeProject about that!
Don't try it, just do it!
|
|
|
|
|
yeap I know this solution, but trust me i must do like i have written. I need this solution so i need to show my controls. I dont want to create child dialog for each page, even it is best way ;/.
All in all thanks for Your reply
df
|
|
|
|
|
Hi everybody. I've made a program in VC++ 6 and I want to convert this program into a DLL file so my program can be called by another one designed by my friend. I tried alot but I couldn't make it.
My program is one dialog. Just two classes the dialog and application class.
I want to call my dialog from the dll file and return a specific value from the dialog to dll, then I want to pass this value to the calling main program (which is my friends program!!).
Thanks in advance,
Muh Ulama
|
|
|
|
|
Declare the classes as __declspec(dllexport) for the DLL, and __declspec(dllimport) for the EXE.
Don't try it, just do it!
|
|
|
|
|
Hi Alexander. Thank u very much for your reply. I'm not expert in VC++; I don't know how to make use of your reply. I have never dealt with dlls before! I just want to view the dialog specified in the dialog class in dll file. I think that the dll should contain the dialog class only then another function should call Domodal method of the dialog object. I think this function must be in the dll file also. Then I'll link this dll to exe file that call the function in dll and this function will view the dialog, and then return a value to exe file according to what the user entered in the dialog.
Plz tell me how to make it and how to view the dialog from dll!!
Thank u very much
Muh Ulama
|
|
|
|
|
how can write multiple line text on a bitmap with TextOut()
Can do it by DrawText()?
|
|
|
|
|
Yes, you can.
Don't try it, just do it!
|
|
|
|