str_cpy not work

Posted By: CocaCola

str_cpy not work - 03/19/18 20:25

hello,
i hate my 3dgs problems but must rely ask you, on my win8.1 (3dgs is installed in c:GStudio8)
why code not work for me?
Code:
#include <acknex.h>
#include <default.c>
#include <strio.c>;
STRING* srt100;
function main()
{
	level_load(NULL);
	str_cpy(srt100,"a"); // string has now empty content
}



iger Error E1515
(X) Invalid function arguments in main

P.S. i have make changes in atypes. but I have install 3dgs new and the first time, the installer told me to restart windows
Posted By: txesmi

Re: str_cpy not work - 03/19/18 20:50

Hi,
when we write
Code:
STRING *str100;


we are declaring an empty STRING pointer.

Code:
STRING *str100 = "";


Declares a STRING pointer that points to a newly created empty STRING struct. But only in global STRING pointers. For local pointers you must create it with str_create and remove it at the end.

Code:
STRING *strLocal = str_create("");
...
str_remove(strLocal);
strLocal = NULL;



Salud!
Posted By: CocaCola

Re: str_cpy not work - 03/19/18 20:58

yea, super thank you txesmi

have i to write
Code:
strLocal = NULL;

after
Code:
str_remove(strLocal);

?
Posted By: txesmi

Re: str_cpy not work - 03/19/18 21:02

Not really, but nullifying your empty pointers is a good practice
Posted By: CocaCola

Re: str_cpy not work - 03/19/18 21:27

i will do it so, thats perfekt for my editor programm, its the basic for diferent projekts i will make with 3dgs.
thank you for your help.
© 2024 lite-C Forums