Gamestudio Links
Zorro Links
Newest Posts
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 827 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
First letter in string #479927
05/05/20 14:20
05/05/20 14:20
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Hi,

sorry for the beginner question, but I cannot find how this make

I'm a need first letter from string I traing find answ. but no work:

Code
		char cFirst = "3CCC3";
		if (cFirst[1] == "C") printf("AAAA");
		if (cFirst[0] == "3") printf("33333");  

have this error:
Quote

Error in 'line 292:
subscript requires array or pointer type
< if (cFirst[1] == "C") printf("AAAA"); >.



Code
		string cFirst = "3CCC3";
		if (cFirst[1] == "C") printf("AAAA");
		if (cFirst[0] == "3") printf("33333");  

this error
Quote

Syntax error: Wrong type EQ:LONG:ARRAY:LONG
< if (cFirst[1] == "C") printf("AAAA"); >


how to test the first letter in the string?

Thank's Milan

Re: First letter in string [Re: Grat] #479928
05/05/20 14:38
05/05/20 14:38
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
A char has single quotes ('), whereas a string has double quotes ("). See the manual:
https://zorro-project.com/manual/en/aarray.htm

Try this:
Code
string cFirst = "3CCC3";
if (cFirst[1] == 'C') printf("AAAA");
if (cFirst[0] == '3') printf("33333");  

Re: First letter in string [Re: Grat] #479930
05/05/20 15:04
05/05/20 15:04
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Thank's this working, I read this page many times, but not see...

laugh


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1