Gamestudio Links
Zorro Links
Newest Posts
Max Number of Strategies in /Strategy folder
by Martin_HH. 06/17/26 07:16
Z9 getting Error 058
by jcl. 06/16/26 09:51
How to select between IB accounts by script?
by AndrewAMD. 06/13/26 15:44
Zorro tutorial ideas?
by AndrewAMD. 06/13/26 15:01
Zorro 3.01 recoded MMI function issue
by 11honza11. 06/13/26 11:40
Stooq now requires an API key
by AndrewAMD. 06/11/26 17:55
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
2 registered members (Martin_HH, 1 invisible), 2,964 guests, and 2 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 Offline
Senior Expert
Quad  Offline
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