Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (dr_panther, 7th_zorro), 1,203 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
str_cpy problem #331364
07/03/10 19:47
07/03/10 19:47
Joined: Apr 2009
Posts: 141
dakilla Offline OP
Member
dakilla  Offline OP
Member

Joined: Apr 2009
Posts: 141
hi,
i have been writing a code for generating a player name using strings for prefixes/suffixes, but the code i have written shows up an error "invalid arguements".

Here is the code:

STRING* prefix1 [20];
STRING* suffix1 [20];
STRING* char_name;

function set_presuf()
{

str_cpy(char_name,"Press Space to Name");

str_cpy(prefix1[1], "Odd");
str_cpy(prefix1[2], "Sar");
str_cpy(prefix1[3], "Stag");
str_cpy(prefix1[4], "Red");
str_cpy(prefix1[5], "Cob");
str_cpy(prefix1[6], "Sol");
str_cpy(prefix1[7], "Tom");
str_cpy(prefix1[8], "Star");
str_cpy(prefix1[9], "Taz");
str_cpy(prefix1[10], "Veer");
str_cpy(prefix1[11], "Pag");
str_cpy(prefix1[12], "Moth");
str_cpy(prefix1[13], "Yelp");
str_cpy(prefix1[14], "Spas");
str_cpy(prefix1[15], "Jun");
str_cpy(prefix1[16], "Spindle");
str_cpy(prefix1[17], "Deak");
str_cpy(prefix1[18], "Pok");
str_cpy(prefix1[19], "Yun");
str_cpy(prefix1[20], "Stab");

str_cpy(suffix1[1], "head");
str_cpy(suffix1[2], "uld");
str_cpy(suffix1[3], "ond");
str_cpy(suffix1[4], "elder");
str_cpy(suffix1[5], "rig");
str_cpy(suffix1[6], "werty");
str_cpy(suffix1[7], "erty");
str_cpy(suffix1[8], "rag");
str_cpy(suffix1[9], "wandil");
str_cpy(suffix1[10], "cup");
str_cpy(suffix1[11], "fire");
str_cpy(suffix1[12], "riddler");
str_cpy(suffix1[13], "dernal");
str_cpy(suffix1[14], "hoble");
str_cpy(suffix1[15], "ernal");
str_cpy(suffix1[16], "ugar");
str_cpy(suffix1[17], "addle");
str_cpy(suffix1[18], "rond");
str_cpy(suffix1[19], "al");
str_cpy(suffix1[20], "indel");

}


thanks in advance, dakilla.


One day there will be an unfixable bug,
That day is not today.
Re: str_cpy problem [Re: dakilla] #331367
07/03/10 20:00
07/03/10 20:00
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
An array begins with 0 and ends with n-1 while n is the size of the array.

This is because [n] shifts the pointer at n adresses to the next element, but your pointer points also to an valid element.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: str_cpy problem [Re: WretchedSid] #331368
07/03/10 20:02
07/03/10 20:02
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
also you should first

prefix1[1] = str_create("Odd");
instead of
str_cpy(prefix1[1], "Odd");


3333333333
Re: str_cpy problem [Re: Quad] #331373
07/03/10 20:42
07/03/10 20:42
Joined: Apr 2009
Posts: 141
dakilla Offline OP
Member
dakilla  Offline OP
Member

Joined: Apr 2009
Posts: 141
ahh, thanks, its now invalid argument free


One day there will be an unfixable bug,
That day is not today.

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