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
kuntilanakAsked:
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.

Infinity08Commented:
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

0
ozoCommented:
no
0
kuntilanakAuthor Commented:
isn't that just similar with:

char forStrings[2000]
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Infinity08Commented:
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.
0
ozoCommented:
Similar, except for the initialization, without which it is not guaranteed that forStrings will be validly null terminated
0
kuntilanakAuthor Commented:
and when you do:

char forStrings[2000] =  " ";

you're basically declaring an array of 2000 pointers to char?
0
Infinity08Commented:
>> 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 " ".
0

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
ozoCommented:
when you do:

char forStrings[2000] =  " ";

you're basically declaring one pointer to an array of 2000 char, starting with {' ', '\0'}
0
kuntilanakAuthor Commented:
ok, thanks guys
0
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
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.