is this valid in both C and C++?

char *forStrings[2000];
strcat(forStrings,"\n     irSTRING string(s");

I tried to compile it using gcc and it gives me error :

:1371: warning: passing argument 1 of âstrcatâ from incompatible pointer type
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

forStrings is basically a pointer-to-pointer-to-char, not a pointer-to-char as expected by strcat.

Did you mean :
char forStrings[2000] = "";
strcat(forStrings,"\n     irSTRING string(s");

Open in new window

kuntilanakAuthor Commented:
isn't that just similar with:

char forStrings[2000]
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

char *forStrings[2000] is not the same as char forStrings[2000]. The first is an array of 2000 pointers-to-char. The second is an array of 2000 char's.
Similar, except for the initialization, without which it is not guaranteed that forStrings will be validly null terminated
kuntilanakAuthor Commented:
and when you do:

char forStrings[2000] =  " ";

you're basically declaring an array of 2000 pointers to char?
>> and when you do:
>> char forStrings[2000] =  " ";
>> you're basically declaring an array of 2000 pointers to char?

No, that's an array of 2000 char's. An array of char's is commonly called a string, so this is a string of 1999 characters (+ one character for the terminating '\0').
That string is initialized to the string " ".

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
when you do:

char forStrings[2000] =  " ";

you're basically declaring one pointer to an array of 2000 char, starting with {' ', '\0'}
kuntilanakAuthor Commented:
ok, thanks guys
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.