Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
StrStrPbrk
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//g++ 7.4.0 ////////////////////////////////////////////////////////////////////////////////StrStrPbrk // //prototypes: //char* strstr(char* scan,char * match); //char* strpbrk (char *scan,char* match); //this code is created by Rezaul Hoque on July 12,2022; //contact:jewelmrh@yahoo.com;Dhaka,Bangladesh;https://rezaulhoque.wordpress.com,https://hoquestake.blogspot.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; ///////////////////////////////////////////////////////////////////////////// #include <iostream> #include <string.h> class NamTel{ char name[25]="hoolablah"; char tel[45]="old city code ---##!\n"; public: NamTel(){} char* getN(){return name;} char* getT(){return tel;} void disp(){ std::cout<<getN()<<"\n"<<getT();} }; int main() { char * p; char *p2; NamTel a; a.disp(); p=strstr(a.getT(),"old city code"); if(p!=NULL) strncpy(p,"new city code",13); a.disp(); char num[7]="---##!"; p2=strpbrk(a.getT(),num); std::cout<<"The telephone number is : "; while (p2!=NULL) { std::cout<<*p2; p2=strpbrk(p2+1,num); } return 0; }
g++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 0.43 sec, absolute running time: 0.15 sec, cpu time: 0.01 sec, memory peak: 5 Mb, absolute service time: 0,63 sec
edit mode
|
history
|
discussion
hoolablah old city code ---##! hoolablah new city code ---##! The telephone number is : ---##!