Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by M_D. 04/26/24 20:22
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (M_D, AndrewAMD, Quad, Ayumi), 806 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
strtok() returns temporary string #481174
08/10/20 11:10
08/10/20 11:10
Joined: May 2020
Posts: 27
Germany
M
Morris Offline OP
Newbie
Morris  Offline OP
Newbie
M

Joined: May 2020
Posts: 27
Germany
It appears that strtok() returns a temporary string which loses its correct value after several calls. The manual at https://manual.zorro-project.com/str_.htm points this out for other functions, but not for strtok(). Unless I am mistaken here, would you mind updating the manual?

Re: strtok() returns temporary string [Re: Morris] #481176
08/10/20 12:15
08/10/20 12:15
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Did you feed strtok a temporary string? It's better to use your own buffer.

I believe strtok actually modifies the original string that you supply, adding null terminators and pointing to a specific character in your supplied buffer to get substrings.

Re: strtok() returns temporary string [Re: Morris] #481179
08/10/20 14:31
08/10/20 14:31
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Yes, strtok modifies the string. It is a standard C function. Temporary strings are only used by specific lite-C string functions.

You can find the documentation about all standard C functions online or in a C book. It's there much more detailed than in the Zorro manual.

Re: strtok() returns temporary string [Re: Morris] #481180
08/10/20 15:31
08/10/20 15:31
Joined: May 2020
Posts: 27
Germany
M
Morris Offline OP
Newbie
Morris  Offline OP
Newbie
M

Joined: May 2020
Posts: 27
Germany
Thank you for your quick reply, gentlemen -- Andrew, yes, you are right, I did feed strtok() a temporary string. So it was the underlying temporary string that was modified outside of strtok(). All is well!


Moderated by  aztec, Inestical, Matt_Coles, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1