str_cpy -- Invalid arguement

Posted By: dakilla

str_cpy -- Invalid arguement - 08/26/11 19:08

hey,
I have recently been having trouble with str_cpy, wherever i use it I get an Invalid-Arguement Error in that function.

For example this produces an invalid arguement in main:
Code:
#include <acknex.h>
#include <default.c>
////////////////////////////
STRING* string1[20];

function main()
{
str_cpy(string1, "Why wont this work");
}



It has been a while since i was programming last so it is probably a stupid mistake that I have not noticed.
Thanks in advance laugh.
Posted By: Aku_Aku

Re: str_cpy -- Invalid arguement - 08/26/11 19:35

When you use an array you have to give the index of the the element where you want to copy the string.
For example:
Code:
str_cpy(string1[2], "Why wont this work");


Posted By: dakilla

Re: str_cpy -- Invalid arguement - 08/26/11 19:41

hey, thanks for the quick reply.

I meant to define 20 characters within the string instead of 20 blank strings shocked (Rustiness mistake!)

Thanks alot grin
Posted By: Aku_Aku

Re: str_cpy -- Invalid arguement - 08/27/11 14:57

To define 20 characters in the string:
STRING* mystring="#20";
This way you'll get a 20 char long allocated string initalized with spaces.
© 2024 lite-C Forums