Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6006419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:32:11+00:00 2026-05-23T01:32:11+00:00

I have a working code using OPENFILENAME. May i know how to use strcat

  • 0

I have a working code using OPENFILENAME. May i know how to use strcat to dynamically control the its parameters

this one is working

//ofn.lpstrFilter = "Rule Files (*.net and *.rul)\0*.rul;*.net\0";   

char filter[100];  
char filterText[100];  
char filterVal[100];
strcpy(filterText, "Rule Files (*.net and *.rul)");   
strcpy(filterVal, "*.rul;*.net");   

I tried using strcat first with ‘\0’ but it only only shows like this
strcat (filter, filterText);
strcat (filter,"\0");
strcat (filter,filterVal);
strcat (filter,"\0");
ofn.lpstrFilter = filter; \\missing \0

And I tried using ‘\\0’
strcat (filter, filterText);
strcat (filter,"\\0");
strcat (filter,filterVal);
strcat (filter,"\\0");

ofn.lpstrFilter = filter; \\now includes the\0

but when i run the program the dialogue box filter shows like this
“Rule Files (*.net and *.rul)\0*.rul;*.net\0”;

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:32:12+00:00Added an answer on May 23, 2026 at 1:32 am

    Using "\\0" won’t do anything useful, that will just put the literal two characters \0 in your string when you want a nul byte. However, strings in C are terminated by '\0' so you can’t use strcat to construct a nul delimited string without a bit of pointer arithmetic.

    So, given these:

    char filterText[] = "Rule Files (*.net and *.rul)";
    char filterVal[]  = "*.rul;*.net";
    char filter[100];
    

    You’ll need to do something like this:

    /*
     * The first one is a straight copy.
     */
    strcpy(filter, filterText);
    
    /*
     * Here we need to offset into filter to right after the
     * nul byte from the first copy.
     */
    strcpy(&filter[strlen(filterText) + 1], filterVal);
    

    A better approach would be to allocate your filter with malloc so that you don’t have to worry about buffer overflows:

    char *filter = malloc(strlen(filterText) + 1 + strlen(filterVal) + 1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just been re-working an old bit of compiler-like code written using bison.
I'm working on a code base in which we have several configurable types. One
I have this legacy code that I am working with and there is code
I have this piece of code (summarized)... AnsiString working(AnsiString format,...) { va_list argptr; AnsiString
I have working code using the spring-ws library to respond to soap requests. I
So I have working code that animates a BG image via a plugin. This
I have working C++ code using swig which creates a struct, passes it to
This working code is using Sproutcore: person = SC.Object.create({ firstName: 'Foo', lastName: 'Bar', fullName:
I have some working Javascript code that generates an RDF/XML document using variables picked
Hi I have been using code similar to this in a piece of automation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.