Gamestudio Links
Zorro Links
Newest Posts
How to select between IB accounts by script?
by Jack_Zodiac. 06/12/26 23:17
Zorro tutorial ideas?
by pr0logic. 06/12/26 13:36
Max Number of Strategies in /Strategy folder
by Martin_HH. 06/12/26 08:50
Stooq now requires an API key
by AndrewAMD. 06/11/26 17:55
Z9 getting Error 058
by k_ivan. 06/10/26 14:38
ZorroGPT
by TipmyPip. 06/10/26 13:07
Z12 live performance
by alx. 06/09/26 20:42
Lapsa's very own thread
by Lapsa. 06/08/26 22:41
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
3 registered members (Quad, TipmyPip, pr0logic), 2,041 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Student_64151, Koti, curry, DeepxKalsi, Samed
19219 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Access single character from STRING #343033
10/03/10 09:56
10/03/10 09:56
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline OP
Serious User
PadMalcom  Offline OP
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Hi, I have a string and want to check the first character like:

Code:
STRING* tempStr = str_create("asd");
  if (tempStr[1] == a) {
    printf("check!");
  }
}



But as you can guess, this does not work wink The comparision is not alowed. Any ideas?

Last edited by PadMalcom; 10/03/10 09:57.
Re: Access single character from STRING [Re: PadMalcom] #343035
10/03/10 09:59
10/03/10 09:59
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Quad Online
Senior Expert
Quad  Online
Senior Expert

Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
(tempStr.chars)[1] == a

or

str_cmp((tempStr.chars)[1],"a")


3333333333
Re: Access single character from STRING [Re: PadMalcom] #343036
10/03/10 10:04
10/03/10 10:04
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Originally Posted By: PadMalcom
Hi, I have a string and want to check the first character like:

Code:
STRING* tempStr = str_create("asd");
  if (tempStr[1] == a) {
    printf("check!");
  }
}




Beside that you don't have a STRING array, it wouldn't even match if it was an char array. You check the second object of the array which is an s.


And @ the one above me: You check a single char against "a" which is nowhere declared. What about this:
Code:
if((tempStr.chars)[0] == 'a')
{

}






Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Access single character from STRING [Re: WretchedSid] #343037
10/03/10 10:10
10/03/10 10:10
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline OP
Serious User
PadMalcom  Offline OP
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
You're right, in my head I'm still using a char* instead of a STRING*! I'm now using "str_chr" since it mainly does what I need. But thanks anyway!


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | 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