Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
show number of space in a string chaine
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
TChart: Wrong default val...
by
wp
[
Today
at 10:14:38 pm]
Pipewire API
by
Fred vS
[
Today
at 10:11:02 pm]
interface and GUID someth...
by
valdir.marcos
[
Today
at 10:05:56 pm]
Hello! Anything new?
by
PascalDragon
[
Today
at 09:39:09 pm]
TSplitter color property ...
by
valdir.marcos
[
Today
at 09:20:11 pm]
Pocketbase
by
steve612
[
Today
at 09:10:08 pm]
ShortStrings vs long stri...
by
valdir.marcos
[
Today
at 08:55:02 pm]
Lazarus Bugfix Release 4....
by
dsiders
[
Today
at 08:53:38 pm]
Any way to "embed" Window...
by
valdir.marcos
[
Today
at 08:42:31 pm]
LazPaint (alpha-blending,...
by
CM630
[
Today
at 08:38:30 pm]
Z80 ZX Spectrum and Syste...
by
d2010
[
Today
at 07:58:28 pm]
could Ardour's YTK be use...
by
fifr
[
Today
at 07:29:40 pm]
Qt6/Wayland clipboard: pa...
by
valdir.marcos
[
Today
at 06:27:22 pm]
[ANN] PasBuild 1.5.0 rele...
by
valdir.marcos
[
Today
at 06:19:54 pm]
Synchronizing Lazarus pro...
by
valdir.marcos
[
Today
at 05:46:58 pm]
class not found
by
SA.Blackmon
[
Today
at 05:27:32 pm]
Register global hotkey
by
Thaddy
[
Today
at 04:20:28 pm]
Crystal report edit
by
Petrus Vorster
[
Today
at 03:12:59 pm]
Faster asin() Was Hiding ...
by
MathMan
[
Today
at 01:58:30 pm]
[ANN] PasBuild 1.6.0 rele...
by
Graeme
[
Today
at 12:19:30 pm]
Debian removes FPC/Lazaru...
by
dbannon
[
Today
at 08:44:10 am]
[revisited] triple click
by
dbannon
[
Today
at 07:45:14 am]
Extended Module Player
by
Gigatron
[March 11, 2026, 11:33:54 pm]
A collection of daily *NI...
by
Roland57
[March 11, 2026, 06:40:37 pm]
88 year D. Knuth changes ...
by
Curt Carpenter
[March 11, 2026, 03:08:55 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: show number of space in a string chaine (Read 1705 times)
whitehat
Jr. Member
Posts: 93
show number of space in a string chaine
«
on:
January 14, 2017, 04:19:55 pm »
there's some problem when i wanna write the number of space in a string chaine tthe program show me
les espace 1ere = 0
les espace 2ere = 0
Code: Pascal
[Select]
[+]
[-]
program
ex
;
uses
wincrt
;
var
ch
:
string
;
procedure
saisie
(
var
ch
:
string
)
;
begin
repeat
writeln
(
'donner le mot'
)
;
readln
(
ch
)
;
until
ch<>
''
;
end
;
procedure
sup
(
var
ch
:
string
)
;
begin
while
pos
(
' '
,
ch
)
<>
0
do
delete
(
ch
,
pos
(
' '
,
ch
)
,
1
)
;
end
;
function
nb
(
ch
:
string
)
:
integer
;
var
i
,
n
:
integer
;
begin
n
:
=
0
;
for
i
:
=
1
to
length
(
ch
)
do
if
ch
[
i
]
=
''
then
n
:
=
n
+
1
;
nb
:
=
n
;
end
;
begin
saisie
(
ch
)
;
writeln
(
'les espace 1ere '
,
nb
(
ch
)
)
;
sup
(
ch
)
;
writeln
(
'les espace 2ere '
,
nb
(
ch
)
)
;
write
(
ch
)
;
end
.
Logged
howardpc
Hero Member
Posts: 4144
Re: show number of space in a string chaine
«
Reply #1 on:
January 14, 2017, 04:46:49 pm »
function nb should be (you're counting spaces, not nulls, right?)
Code: Pascal
[Select]
[+]
[-]
function
nb
(
ch
:
string
)
:
integer
;
var
i
,
n
:
integer
;
begin
n
:
=
0
;
for
i
:
=
1
to
length
(
ch
)
do
if
(
ch
[
i
]
=
' '
)
then
n
:
=
n
+
1
;
nb
:
=
n
;
end
;
Logged
whitehat
Jr. Member
Posts: 93
Re: show number of space in a string chaine
«
Reply #2 on:
January 14, 2017, 04:54:27 pm »
yes true
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
show number of space in a string chaine
TinyPortal
© 2005-2018