LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-11-2004, 09:03 PM   #1
Scrag
Member
 
Registered: Mar 2004
Location: Wisconsin
Distribution: Kali Linux
Posts: 131

Rep: Reputation: 15
Need help with C function/strings


I need help writing a C function that will be passed an http path, and the function will remove the %20 for space that is commonly in the file/path name. For example, the web browser asks for a file called "Cool File.mpg", but http displays it as "Cool%20File.mpg", I need a function that extracts the %20 from the file name, and returns the path without the %20 in it.. I've done this with a single char but not a string, and Im not sure how to get this started.

THANKS

 
Old 12-12-2004, 12:34 AM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
You might check the man page for strstr. If you can use something outside of the standard C library, abnd you are familiar with regular expressions, you might want to look at libpcre, which is a C library that can do Perl Compatible regular expressions. I've never used it before though, so I'm not sure if it can do what you want.
 
Old 12-12-2004, 12:54 PM   #3
Scrag
Member
 
Registered: Mar 2004
Location: Wisconsin
Distribution: Kali Linux
Posts: 131

Original Poster
Rep: Reputation: 15
Cool! strstr() is what I need. Hhmmmm....I guess I need to loop through the string now and fugure out how to replace each instance of "%20" with "\ ". Any suggestions on how I should to this, or is there already a function in place to replace a certain string in a string?

Thanks again for the help!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to find duplicate strings in vertical column of strings markhod Programming 7 11-02-2005 04:04 AM
c++ strings-strcmp function...... sachitha Programming 4 09-12-2004 07:28 AM
what are the Hexadecimal function and ASCII function in Perl Bassam Programming 1 06-03-2004 01:44 AM
A main can be changed by a function local without passing anything to the function? ananthbv Programming 10 05-04-2004 01:31 PM
Perl exec function in linux (and system-function) nazula Programming 1 04-19-2004 12:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration