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

  • SEARCH
  • Home
  • 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 8232663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:54:26+00:00 2026-06-07T17:54:26+00:00

I have been given a static library to work with that accepts arguments as

  • 0

I have been given a static library to work with that accepts arguments as a space delimited char.

Method in library

int saveFile(char* param);

I am passing it the Documents file path to save to

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
std::string str = [documentsDirectory cStringUsingEncoding:[NSString defaultCStringEncoding]];
const char * filePath = str.c_str();
char pa[1024];
pa[0] = 0;
strcat(pa, filePath);
saveFile(pa);

My problem is that the IOS file path has spaces in it and this causes the library to split the path in those places. I have tried escaping the spaces with a “\” and of course, placing the path in quotes does not work in this instance. For example below…

/Users/bigbadowl/Library/Application Support/iPhone Simulator/5.1/Applications/649D2EEB-8C88-42C7-9A74-21629570B1D0/Documents

Would be split in to

/Users/bigbadowl/Library/Application
Support/iPhone
Simulator/5.1/Applications/649D2EEB-8C88-42C7-9A74-21629570B1D0/Documents

Any ideas would be appreciated.

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-06-07T17:54:27+00:00Added an answer on June 7, 2026 at 5:54 pm

    One solution would be replacing the spaces in the original string with an unlikely-to-be-used character (such as #), perform the library manipulations, and then revert all the occurrences of this character back to spaces. Something along the lines of:

    // ...
    std::replace(str .begin(), str .end(), ' ', '#');  // Replace spaces with #
    const char * filePath = str.c_str();
    char pa[1024] = {0};
    strcat(pa, str.c_str());
    std::replace(str .begin(), str .end(), '#', ' ');  // Replace # with spaces
    // ...
    

    Of course, you won’t get the desired behavior if the original string contains this character. You could always test this and select another character, so this shouldn’t be a problem, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

gcc 4.5.1 Fedora 14 Linux I have this static library that was build from
We have been given some code that does a URLRequest call which is really
Good day, I have been given an assignment that gets data off a CSV
I have been given a task that can be simplified to this scenario: Customers
I have been given control of a web site in Classic ASP. What is
I have been given some poorly formatted data and need to pull numbers out
I have been given an exercise to solve the zebra puzzle using a constraint
I have been given the below .NET question in an interview. I don’t know
We have been given a site xyz.com, in which the home page has images
I have been given the following request. Please give 7% of the current contacts

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.