GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - betaWeb/str_replace: A very naive implementation of the PHP function `str_replace` in C.

BranchesTags
Open more actions menu

Latest commit

 

History

4 Commits
4 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
README.md
README.md
 
 
str_replace.c
str_replace.c
 
 
str_replace.h
str_replace.h
 
 

Repository files navigation

Implementation of str_replace in C

This is a very naive implementation of the PHP function str_replace in C. I wrote it in purpuse to learn C basics.

Basically, it search for the index of the searched word in the subject string.

If no index found, then it returns the subject.

Otherwize it splits the subject string into 3 parts :

  • prefix : all chars before the searched word
  • searched word
  • suffix : all chars after the searched word and it replaces the searched word by the replace parameter.

Finally, it join prefix with replace and suffix, and returns it as string.

Basic usage

char *original_str, *replaced_str;
   
original_str = "This is a very powerful implementation of str_replace function";
replaced_str = str_replace("powerful", "naive", original_str); 
// --> RESULT : "This is a very naive implementation of str_replace function"

free(replaced_str);

About

A very naive implementation of the PHP function `str_replace` in C.

Topics

cnaive-algorithmreplacestr-replacestring-manipulationstring-replace

Resources

Readme
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.