So I could copy it first , then run the '|' <--> '\0' switch.
I will try it. Can't believe I didn't see it.
Main Topics
Browse All TopicsI get a char * to my function argument. It is a string that I parse to create a few strings from.
Example:
"var1,var2,1234,Text (.txt)|*.txt|Bitmap (.bmp)|*.bmp||"
I have a function that parses the strings so I end up with one :
"Text (.txt)|*.txt|Bitmap (.bmp)|*.bmp||"
So I replace the '|' with '\0' :
"Text (.txt)\0*.txt\0Bitmap (.bmp)\0*.bmp\0\0"
char filter[512];
strcpy(filter,"Text (.txt)\0*.txt\0Bitmap (.bmp)\0*.bmp\0\0 ") ;
Now it should be in the format to set my lpstrFilter:
OPENFILENAME opfn;
opfn.lpstrFilter = filter;
and try to pass it as lpstrFilter to GetOpenFileName(&opfn)
The problem is that the filter doesn't work properly. I get The First part working perfectly.
- Text (.txt)
but the other options in the filter comboBox are crazy unrecognizable characters. (2 lines of them)
How can I get this to work?
// here is the function that changes '|' to '\0'
// for(i=0;i<strlen(filters);
// {
// if(filters[i] == '|')
// {
// filters[i] = '\0';
// }
// }
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: AlexFMPosted on 2005-03-01 at 03:08:15ID: 13427899
strcpy function stops copying in the first NULL, you need to use memcpy instead of it.
char filter[512];
memcpy(filter, <string with NULLs in the middle>, <strlen of original string + 2>);